src/java.base/share/classes/java/text/DateFormatSymbols.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58288 48e480e56aad
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 48660
diff changeset
     2
 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1996 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *   The original version of this source code and documentation is copyrighted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * materials are provided under terms of a License Agreement between Taligent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * and Sun. This technology is protected by multiple US and International
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * patents. This notice and attribution to Taligent may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *   Taligent is a registered trademark of Taligent, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
package java.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.lang.ref.SoftReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.text.spi.DateFormatSymbolsProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.util.Locale;
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
    48
import java.util.Objects;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.util.ResourceBundle;
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
    50
import java.util.concurrent.ConcurrentHashMap;
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
    51
import java.util.concurrent.ConcurrentMap;
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    52
import sun.util.locale.provider.CalendarDataUtility;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
    53
import sun.util.locale.provider.LocaleProviderAdapter;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
    54
import sun.util.locale.provider.LocaleServiceProviderPool;
15260
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14765
diff changeset
    55
import sun.util.locale.provider.ResourceBundleBasedAdapter;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
    56
import sun.util.locale.provider.TimeZoneNameUtility;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/**
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    59
 * {@code DateFormatSymbols} is a public class for encapsulating
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * localizable date-time formatting data, such as the names of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * months, the names of the days of the week, and the time zone data.
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    62
 * {@code SimpleDateFormat} uses
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    63
 * {@code DateFormatSymbols} to encapsulate this information.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    66
 * Typically you shouldn't use {@code DateFormatSymbols} directly.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * Rather, you are encouraged to create a date-time formatter with the
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    68
 * {@code DateFormat} class's factory methods: {@code getTimeInstance},
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    69
 * {@code getDateInstance}, or {@code getDateTimeInstance}.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    70
 * These methods automatically create a {@code DateFormatSymbols} for
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * the formatter so that you don't have to. After the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * formatter is created, you may modify its format pattern using the
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    73
 * {@code setPattern} method. For more information about
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    74
 * creating formatters using {@code DateFormat}'s factory methods,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * see {@link DateFormat}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * If you decide to create a date-time formatter with a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * format pattern for a specific locale, you can do so with:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * new SimpleDateFormat(aPattern, DateFormatSymbols.getInstance(aLocale)).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    86
 * <p>If the locale contains "rg" (region override)
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    87
 * <a href="../util/Locale.html#def_locale_extension">Unicode extension</a>,
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    88
 * the symbols are overridden for the designated region.
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
    89
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    91
 * {@code DateFormatSymbols} objects are cloneable. When you obtain
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    92
 * a {@code DateFormatSymbols} object, feel free to modify the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * date-time formatting data. For instance, you can replace the localized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * date-time format pattern characters with the ones that you feel easy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * to remember. Or you can change the representative cities
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * to your favorite ones.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    99
 * New {@code DateFormatSymbols} subclasses may be added to support
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   100
 * {@code SimpleDateFormat} for date-time formatting for additional locales.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @see          DateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @see          SimpleDateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @see          java.util.SimpleTimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * @author       Chen-Lieh Huang
45434
4582657c7260 8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents: 42930
diff changeset
   106
 * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
public class DateFormatSymbols implements Serializable, Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Construct a DateFormatSymbols object by loading format data from
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   112
     * resources for the default {@link java.util.Locale.Category#FORMAT FORMAT}
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   113
     * locale. This constructor can only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * construct instances for the locales supported by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * runtime environment, not for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * {@link #getInstance(Locale) getInstance} method.
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   119
     * <p>This is equivalent to calling
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   120
     * {@link #DateFormatSymbols(Locale)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   121
     *     DateFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @see #getInstance()
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   123
     * @see java.util.Locale#getDefault(java.util.Locale.Category)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   124
     * @see java.util.Locale.Category#FORMAT
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   125
     * @throws     java.util.MissingResourceException
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *             if the resources for the default locale cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *             found or cannot be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public DateFormatSymbols()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    {
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   131
        initializeData(Locale.getDefault(Locale.Category.FORMAT));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Construct a DateFormatSymbols object by loading format data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * resources for the given locale. This constructor can only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * construct instances for the locales supported by the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * runtime environment, not for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * implementations. For full locale coverage, use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * {@link #getInstance(Locale) getInstance} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
19054
a64012cb49d6 8021108: Clean up doclint warnings and errors in java.text package
peytoia
parents: 17708
diff changeset
   143
     * @param locale the desired locale
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @see #getInstance(Locale)
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   145
     * @throws     java.util.MissingResourceException
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *             if the resources for the specified locale cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *             found or cannot be loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public DateFormatSymbols(Locale locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        initializeData(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   155
     * Constructs an uninitialized DateFormatSymbols.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   156
     */
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   157
    private DateFormatSymbols(boolean flag) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   158
    }
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   159
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   160
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Era strings. For example: "AD" and "BC".  An array of 2 strings,
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   162
     * indexed by {@code Calendar.BC} and {@code Calendar.AD}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    String eras[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Month strings. For example: "January", "February", etc.  An array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * of 13 strings (some calendars have 13 months), indexed by
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   170
     * {@code Calendar.JANUARY}, {@code Calendar.FEBRUARY}, etc.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    String months[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Short month strings. For example: "Jan", "Feb", etc.  An array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * 13 strings (some calendars have 13 months), indexed by
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   178
     * {@code Calendar.JANUARY}, {@code Calendar.FEBRUARY}, etc.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    String shortMonths[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Weekday strings. For example: "Sunday", "Monday", etc.  An array
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   186
     * of 8 strings, indexed by {@code Calendar.SUNDAY},
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   187
     * {@code Calendar.MONDAY}, etc.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   188
     * The element {@code weekdays[0]} is ignored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    String weekdays[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Short weekday strings. For example: "Sun", "Mon", etc.  An array
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   195
     * of 8 strings, indexed by {@code Calendar.SUNDAY},
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   196
     * {@code Calendar.MONDAY}, etc.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   197
     * The element {@code shortWeekdays[0]} is ignored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    String shortWeekdays[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * AM and PM strings. For example: "AM" and "PM".  An array of
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   204
     * 2 strings, indexed by {@code Calendar.AM} and
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   205
     * {@code Calendar.PM}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    String ampms[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Localized names of time zones in this locale.  This is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * where <em>m</em> is at least 5.  Each of the <em>n</em> rows is an
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   214
     * entry containing the localized names for a single {@code TimeZone}.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   215
     * Each such row contains (with {@code i} ranging from
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * 0..<em>n</em>-1):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <ul>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   218
     * <li>{@code zoneStrings[i][0]} - time zone ID</li>
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   219
     * <li>{@code zoneStrings[i][1]} - long name of zone in standard
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   221
     * <li>{@code zoneStrings[i][2]} - short name of zone in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * standard time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   223
     * <li>{@code zoneStrings[i][3]} - long name of zone in daylight
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * saving time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   225
     * <li>{@code zoneStrings[i][4]} - short name of zone in daylight
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * The zone ID is <em>not</em> localized; it's one of the valid IDs of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * the {@link java.util.TimeZone TimeZone} class that are not
39319
d32c7b64cb93 7090039: Wrong link in comment of java.text.DateFormatSymbols
peytoia
parents: 36951
diff changeset
   230
     * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * All other entries are localized names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @see java.util.TimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    String zoneStrings[][] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * Indicates that zoneStrings is set externally with setZoneStrings() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    transient boolean isZoneStringsSet = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Unlocalized date-time pattern characters. For example: 'y', 'd', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * All locales use the same these unlocalized pattern characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   246
    static final String  patternChars = "GyMdkHmsSEDFwWahKzZYuXL";
6491
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   247
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   248
    static final int PATTERN_ERA                  =  0; // G
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   249
    static final int PATTERN_YEAR                 =  1; // y
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   250
    static final int PATTERN_MONTH                =  2; // M
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   251
    static final int PATTERN_DAY_OF_MONTH         =  3; // d
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   252
    static final int PATTERN_HOUR_OF_DAY1         =  4; // k
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   253
    static final int PATTERN_HOUR_OF_DAY0         =  5; // H
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   254
    static final int PATTERN_MINUTE               =  6; // m
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   255
    static final int PATTERN_SECOND               =  7; // s
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   256
    static final int PATTERN_MILLISECOND          =  8; // S
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   257
    static final int PATTERN_DAY_OF_WEEK          =  9; // E
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   258
    static final int PATTERN_DAY_OF_YEAR          = 10; // D
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   259
    static final int PATTERN_DAY_OF_WEEK_IN_MONTH = 11; // F
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   260
    static final int PATTERN_WEEK_OF_YEAR         = 12; // w
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   261
    static final int PATTERN_WEEK_OF_MONTH        = 13; // W
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   262
    static final int PATTERN_AM_PM                = 14; // a
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   263
    static final int PATTERN_HOUR1                = 15; // h
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   264
    static final int PATTERN_HOUR0                = 16; // K
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   265
    static final int PATTERN_ZONE_NAME            = 17; // z
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   266
    static final int PATTERN_ZONE_VALUE           = 18; // Z
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   267
    static final int PATTERN_WEEK_YEAR            = 19; // Y
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   268
    static final int PATTERN_ISO_DAY_OF_WEEK      = 20; // u
6497
22752a2b3413 4919632: RFE: SimpleDateFormat should fully support ISO8601 standard for timezone
okutsu
parents: 6491
diff changeset
   269
    static final int PATTERN_ISO_ZONE             = 21; // X
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   270
    static final int PATTERN_MONTH_STANDALONE     = 22; // L
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Localized date-time pattern characters. For example, a locale may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * wish to use 'u' rather than 'y' to represent years in its date format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * pattern strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * This string must be exactly 18 characters long, with the index of
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   277
     * the characters described by {@code DateFormat.ERA_FIELD},
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   278
     * {@code DateFormat.YEAR_FIELD}, etc.  Thus, if the string were
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * "Xz...", then localized patterns would use 'X' for era and 'z' for year.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    String  localPatternChars = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * The locale which is used for initializing this DateFormatSymbols object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    Locale locale = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /* use serialVersionUID from JDK 1.1.4 for interoperability */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 48660
diff changeset
   293
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    static final long serialVersionUID = -5987973545549424702L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Returns an array of all locales for which the
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   298
     * {@code getInstance} methods of this class can return
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * localized instances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * The returned array represents the union of locales supported by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * Java runtime and by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   303
     * implementations.  It must contain at least a {@code Locale}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * instance equal to {@link java.util.Locale#US Locale.US}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @return An array of locales for which localized
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   307
     *         {@code DateFormatSymbols} instances are available.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public static Locale[] getAvailableLocales() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        LocaleServiceProviderPool pool=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return pool.getAvailableLocales();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   317
     * Gets the {@code DateFormatSymbols} instance for the default
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   318
     * locale.  This method provides access to {@code DateFormatSymbols}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * implementations.
16010
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   323
     * <p>This is equivalent to calling {@link #getInstance(Locale)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   324
     *     getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   325
     * @see java.util.Locale#getDefault(java.util.Locale.Category)
2727163b5df5 7092447: Clarify the default locale used in each locale sensitive operation
naoto
parents: 15260
diff changeset
   326
     * @see java.util.Locale.Category#FORMAT
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   327
     * @return a {@code DateFormatSymbols} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    public static final DateFormatSymbols getInstance() {
6489
9e7015635425 4700857: RFE: separating user locale and user interface locale
naoto
parents: 5506
diff changeset
   331
        return getInstance(Locale.getDefault(Locale.Category.FORMAT));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   335
     * Gets the {@code DateFormatSymbols} instance for the specified
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   336
     * locale.  This method provides access to {@code DateFormatSymbols}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * instances for locales supported by the Java runtime itself as well
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * as for those supported by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @param locale the given locale.
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   342
     * @return a {@code DateFormatSymbols} instance.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   343
     * @throws    NullPointerException if {@code locale} is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public static final DateFormatSymbols getInstance(Locale locale) {
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   347
        DateFormatSymbols dfs = getProviderInstance(locale);
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   348
        if (dfs != null) {
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   349
            return dfs;
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   350
        }
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   351
        throw new RuntimeException("DateFormatSymbols instance creation failed.");
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   352
    }
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   353
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   354
    /**
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   355
     * Returns a DateFormatSymbols provided by a provider or found in
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   356
     * the cache. Note that this method returns a cached instance,
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   357
     * not its clone. Therefore, the instance should never be given to
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   358
     * an application.
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   359
     */
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   360
    static final DateFormatSymbols getInstanceRef(Locale locale) {
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   361
        DateFormatSymbols dfs = getProviderInstance(locale);
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   362
        if (dfs != null) {
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   363
            return dfs;
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   364
        }
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   365
        throw new RuntimeException("DateFormatSymbols instance creation failed.");
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   366
    }
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   367
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   368
    private static DateFormatSymbols getProviderInstance(Locale locale) {
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   369
        LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   370
        DateFormatSymbolsProvider provider = adapter.getDateFormatSymbolsProvider();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   371
        DateFormatSymbols dfsyms = provider.getInstance(locale);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   372
        if (dfsyms == null) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   373
            provider = LocaleProviderAdapter.forJRE().getDateFormatSymbolsProvider();
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   374
            dfsyms = provider.getInstance(locale);
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   375
        }
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   376
        return dfsyms;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * Gets era strings. For example: "AD" and "BC".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @return the era strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public String[] getEras() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return Arrays.copyOf(eras, eras.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Sets era strings. For example: "AD" and "BC".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @param newEras the new era strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    public void setEras(String[] newEras) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        eras = Arrays.copyOf(newEras, newEras.length);
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   393
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Gets month strings. For example: "January", "February", etc.
48660
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   398
     * An array with either 12 or 13 elements will be returned depending
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   399
     * on whether or not {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER}
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   400
     * is supported. Use
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   401
     * {@link java.util.Calendar#JANUARY Calendar.JANUARY},
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   402
     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY},
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   403
     * etc. to index the result array.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   404
     *
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   405
     * <p>If the language requires different forms for formatting and
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   406
     * stand-alone usages, this method returns month names in the
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   407
     * formatting form. For example, the preferred month name for
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   408
     * January in the Czech language is <em>ledna</em> in the
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   409
     * formatting form, while it is <em>leden</em> in the stand-alone
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   410
     * form. This method returns {@code "ledna"} in this case. Refer
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   411
     * to the <a href="http://unicode.org/reports/tr35/#Calendar_Elements">
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   412
     * Calendar Elements in the Unicode Locale Data Markup Language
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   413
     * (LDML) specification</a> for more details.
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   414
     *
48660
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   415
     * @implSpec This method returns 13 elements since
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   416
     * {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER} is supported.
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   417
     * @return the month strings.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    public String[] getMonths() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return Arrays.copyOf(months, months.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * Sets month strings. For example: "January", "February", etc.
40391
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   425
     * @param newMonths the new month strings. The array should
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   426
     * be indexed by {@link java.util.Calendar#JANUARY Calendar.JANUARY},
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   427
     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    public void setMonths(String[] newMonths) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        months = Arrays.copyOf(newMonths, newMonths.length);
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   431
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * Gets short month strings. For example: "Jan", "Feb", etc.
48660
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   436
     * An array with either 12 or 13 elements will be returned depending
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   437
     * on whether or not {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER}
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   438
     * is supported. Use
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   439
     * {@link java.util.Calendar#JANUARY Calendar.JANUARY},
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   440
     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY},
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   441
     * etc. to index the result array.
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   442
     *
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   443
     * <p>If the language requires different forms for formatting and
39490
1450367e1082 8055900: j.t.SimpleDateFormat spec needs to be clarified regarding month patterns
nishjain
parents: 39319
diff changeset
   444
     * stand-alone usages, this method returns short month names in
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   445
     * the formatting form. For example, the preferred abbreviation
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   446
     * for January in the Catalan language is <em>de gen.</em> in the
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   447
     * formatting form, while it is <em>gen.</em> in the stand-alone
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   448
     * form. This method returns {@code "de gen."} in this case. Refer
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   449
     * to the <a href="http://unicode.org/reports/tr35/#Calendar_Elements">
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   450
     * Calendar Elements in the Unicode Locale Data Markup Language
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   451
     * (LDML) specification</a> for more details.
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   452
     *
48660
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   453
     * @implSpec This method returns 13 elements since
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   454
     * {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER} is supported.
693052e16ac9 8146656: Wrong Months Array for DateFormatSymbols
rgoel
parents: 48251
diff changeset
   455
     * @return the short month strings.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    public String[] getShortMonths() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return Arrays.copyOf(shortMonths, shortMonths.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * Sets short month strings. For example: "Jan", "Feb", etc.
40391
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   463
     * @param newShortMonths the new short month strings. The array should
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   464
     * be indexed by {@link java.util.Calendar#JANUARY Calendar.JANUARY},
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   465
     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    public void setShortMonths(String[] newShortMonths) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        shortMonths = Arrays.copyOf(newShortMonths, newShortMonths.length);
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   469
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * Gets weekday strings. For example: "Sunday", "Monday", etc.
40391
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   474
     * @return the weekday strings. Use
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   475
     * {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   476
     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc. to index
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   477
     * the result array.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    public String[] getWeekdays() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        return Arrays.copyOf(weekdays, weekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * Sets weekday strings. For example: "Sunday", "Monday", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @param newWeekdays the new weekday strings. The array should
40391
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   486
     * be indexed by {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   487
     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    public void setWeekdays(String[] newWeekdays) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        weekdays = Arrays.copyOf(newWeekdays, newWeekdays.length);
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   491
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * Gets short weekday strings. For example: "Sun", "Mon", etc.
40391
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   496
     * @return the short weekday strings. Use
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   497
     * {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   498
     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc. to index
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   499
     * the result array.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    public String[] getShortWeekdays() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        return Arrays.copyOf(shortWeekdays, shortWeekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * Sets short weekday strings. For example: "Sun", "Mon", etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @param newShortWeekdays the new short weekday strings. The array should
40391
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   508
     * be indexed by {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
7c0d6665aef9 8129555: DateFormatSymbols: month-related methods must refer to Calendar constants
nishjain
parents: 39490
diff changeset
   509
     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public void setShortWeekdays(String[] newShortWeekdays) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        shortWeekdays = Arrays.copyOf(newShortWeekdays, newShortWeekdays.length);
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   513
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * Gets ampm strings. For example: "AM" and "PM".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @return the ampm strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    public String[] getAmPmStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        return Arrays.copyOf(ampms, ampms.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * Sets ampm strings. For example: "AM" and "PM".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * @param newAmpms the new ampm strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    public void setAmPmStrings(String[] newAmpms) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        ampms = Arrays.copyOf(newAmpms, newAmpms.length);
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   530
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * Gets time zone strings.  Use of this method is discouraged; use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * {@link java.util.TimeZone#getDisplayName() TimeZone.getDisplayName()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * The value returned is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * where <em>m</em> is at least 5.  Each of the <em>n</em> rows is an
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   541
     * entry containing the localized names for a single {@code TimeZone}.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   542
     * Each such row contains (with {@code i} ranging from
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * 0..<em>n</em>-1):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * <ul>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   545
     * <li>{@code zoneStrings[i][0]} - time zone ID</li>
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   546
     * <li>{@code zoneStrings[i][1]} - long name of zone in standard
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   548
     * <li>{@code zoneStrings[i][2]} - short name of zone in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * standard time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   550
     * <li>{@code zoneStrings[i][3]} - long name of zone in daylight
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * saving time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   552
     * <li>{@code zoneStrings[i][4]} - short name of zone in daylight
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * The zone ID is <em>not</em> localized; it's one of the valid IDs of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * the {@link java.util.TimeZone TimeZone} class that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * All other entries are localized names.  If a zone does not implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * daylight saving time, the daylight saving time names should not be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * If {@link #setZoneStrings(String[][]) setZoneStrings} has been called
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   562
     * on this {@code DateFormatSymbols} instance, then the strings
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * provided by that call are returned. Otherwise, the returned array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * contains names provided by the Java runtime and by installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @return the time zone strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * @see #setZoneStrings(String[][])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    public String[][] getZoneStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        return getZoneStringsImpl(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Sets time zone strings.  The argument must be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * where <em>m</em> is at least 5.  Each of the <em>n</em> rows is an
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   579
     * entry containing the localized names for a single {@code TimeZone}.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   580
     * Each such row contains (with {@code i} ranging from
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * 0..<em>n</em>-1):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * <ul>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   583
     * <li>{@code zoneStrings[i][0]} - time zone ID</li>
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   584
     * <li>{@code zoneStrings[i][1]} - long name of zone in standard
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   586
     * <li>{@code zoneStrings[i][2]} - short name of zone in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * standard time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   588
     * <li>{@code zoneStrings[i][3]} - long name of zone in daylight
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * saving time</li>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   590
     * <li>{@code zoneStrings[i][4]} - short name of zone in daylight
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * saving time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * The zone ID is <em>not</em> localized; it's one of the valid IDs of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * the {@link java.util.TimeZone TimeZone} class that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * All other entries are localized names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @param newZoneStrings the new time zone strings.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57956
diff changeset
   599
     * @throws    IllegalArgumentException if the length of any row in
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   600
     *    {@code newZoneStrings} is less than 5
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   601
     * @throws    NullPointerException if {@code newZoneStrings} is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * @see #getZoneStrings()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    public void setZoneStrings(String[][] newZoneStrings) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        String[][] aCopy = new String[newZoneStrings.length][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        for (int i = 0; i < newZoneStrings.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            int len = newZoneStrings[i].length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            if (len < 5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            aCopy[i] = Arrays.copyOf(newZoneStrings[i], len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        zoneStrings = aCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        isZoneStringsSet = true;
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   615
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * Gets localized date-time pattern characters. For example: 'u', 't', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @return the localized date-time pattern characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    public String getLocalPatternChars() {
6491
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   623
        return localPatternChars;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * Sets localized date-time pattern characters. For example: 'u', 't', etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * @param newLocalPatternChars the new localized date-time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * pattern characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    public void setLocalPatternChars(String newLocalPatternChars) {
6491
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   632
        // Call toString() to throw an NPE in case the argument is null
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   633
        localPatternChars = newLocalPatternChars.toString();
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   634
        cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * Overrides Cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    public Object clone()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        try
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            DateFormatSymbols other = (DateFormatSymbols)super.clone();
36253
652d06266511 8151393: Revert changes for JDK-8087104
darcy
parents: 36241
diff changeset
   645
            copyMembers(this, other);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            return other;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        } catch (CloneNotSupportedException e) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 7003
diff changeset
   648
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * Override hashCode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * Generates a hash code for the DateFormatSymbols object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     */
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   656
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    public int hashCode() {
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   658
        int hashCode = cachedHashCode;
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   659
        if (hashCode == 0) {
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   660
            hashCode = 5;
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   661
            hashCode = 11 * hashCode + Arrays.hashCode(eras);
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   662
            hashCode = 11 * hashCode + Arrays.hashCode(months);
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   663
            hashCode = 11 * hashCode + Arrays.hashCode(shortMonths);
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   664
            hashCode = 11 * hashCode + Arrays.hashCode(weekdays);
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   665
            hashCode = 11 * hashCode + Arrays.hashCode(shortWeekdays);
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   666
            hashCode = 11 * hashCode + Arrays.hashCode(ampms);
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   667
            hashCode = 11 * hashCode + Arrays.deepHashCode(getZoneStringsWrapper());
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   668
            hashCode = 11 * hashCode + Objects.hashCode(localPatternChars);
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 25859
diff changeset
   669
            if (hashCode != 0) {
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 25859
diff changeset
   670
                cachedHashCode = hashCode;
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 25859
diff changeset
   671
            }
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   672
        }
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   673
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   674
        return hashCode;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * Override equals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    public boolean equals(Object obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        if (this == obj) return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (obj == null || getClass() != obj.getClass()) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        DateFormatSymbols that = (DateFormatSymbols) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        return (Arrays.equals(eras, that.eras)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                && Arrays.equals(months, that.months)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                && Arrays.equals(shortMonths, that.shortMonths)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                && Arrays.equals(weekdays, that.weekdays)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                && Arrays.equals(shortWeekdays, that.shortWeekdays)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                && Arrays.equals(ampms, that.ampms)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                && Arrays.deepEquals(getZoneStringsWrapper(), that.getZoneStringsWrapper())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                && ((localPatternChars != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                  && localPatternChars.equals(that.localPatternChars))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                 || (localPatternChars == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                  && that.localPatternChars == null)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    // =======================privates===============================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * Useful constant for defining time zone offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    static final int millisPerHour = 60*60*1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    /**
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   706
     * Cache to hold DateFormatSymbols instances per Locale.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     */
36253
652d06266511 8151393: Revert changes for JDK-8087104
darcy
parents: 36241
diff changeset
   708
    private static final ConcurrentMap<Locale, SoftReference<DateFormatSymbols>> cachedInstances
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   709
        = new ConcurrentHashMap<>(3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 25859
diff changeset
   711
    private transient int lastZoneIndex;
12549
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   712
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   713
    /**
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   714
     * Cached hash code
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   715
     */
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 25859
diff changeset
   716
    transient volatile int cachedHashCode;
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   717
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   718
    /**
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   719
     * Initializes this DateFormatSymbols with the locale data. This method uses
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   720
     * a cached DateFormatSymbols instance for the given locale if available. If
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   721
     * there's no cached one, this method creates an uninitialized instance and
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   722
     * populates its fields from the resource bundle for the locale, and caches
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   723
     * the instance. Note: zoneStrings isn't initialized in this method.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   724
     */
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   725
    private void initializeData(Locale locale) {
36253
652d06266511 8151393: Revert changes for JDK-8087104
darcy
parents: 36241
diff changeset
   726
        SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
652d06266511 8151393: Revert changes for JDK-8087104
darcy
parents: 36241
diff changeset
   727
        DateFormatSymbols dfs;
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   728
        if (ref == null || (dfs = ref.get()) == null) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   729
            if (ref != null) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   730
                // Remove the empty SoftReference
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   731
                cachedInstances.remove(locale, ref);
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   732
            }
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   733
            dfs = new DateFormatSymbols(false);
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   734
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   735
            // check for region override
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   736
            Locale override = CalendarDataUtility.findRegionOverride(locale);
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   737
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   738
            // Initialize the fields from the ResourceBundle for locale.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   739
            LocaleProviderAdapter adapter
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   740
                = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, override);
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   741
            // Avoid any potential recursions
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   742
            if (!(adapter instanceof ResourceBundleBasedAdapter)) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   743
                adapter = LocaleProviderAdapter.getResourceBundleBased();
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   744
            }
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   745
            ResourceBundle resource
48251
57148c79bd75 8176841: Additional Unicode Language-Tag Extensions
naoto
parents: 47216
diff changeset
   746
                = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(override);
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   747
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   748
            dfs.locale = locale;
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   749
            // JRE and CLDR use different keys
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   750
            // JRE: Eras, short.Eras and narrow.Eras
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   751
            // CLDR: long.Eras, Eras and narrow.Eras
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   752
            if (resource.containsKey("Eras")) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   753
                dfs.eras = resource.getStringArray("Eras");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   754
            } else if (resource.containsKey("long.Eras")) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   755
                dfs.eras = resource.getStringArray("long.Eras");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   756
            } else if (resource.containsKey("short.Eras")) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   757
                dfs.eras = resource.getStringArray("short.Eras");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   758
            }
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   759
            dfs.months = resource.getStringArray("MonthNames");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   760
            dfs.shortMonths = resource.getStringArray("MonthAbbreviations");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   761
            dfs.ampms = resource.getStringArray("AmPmMarkers");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   762
            dfs.localPatternChars = resource.getString("DateTimePatternChars");
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   763
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   764
            // Day of week names are stored in a 1-based array.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   765
            dfs.weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   766
            dfs.shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   767
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   768
            // Put dfs in the cache
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   769
            ref = new SoftReference<>(dfs);
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   770
            SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   771
            if (x != null) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   772
                DateFormatSymbols y = x.get();
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   773
                if (y == null) {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   774
                    // Replace the empty SoftReference with ref.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   775
                    cachedInstances.replace(locale, x, ref);
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   776
                } else {
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   777
                    ref = x;
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   778
                    dfs = y;
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   779
                }
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   780
            }
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   781
        }
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   782
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   783
        // Copy the field values from dfs to this instance.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   784
        copyMembers(dfs, this);
7003
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   785
    }
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   786
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   787
    private static String[] toOneBasedArray(String[] src) {
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   788
        int len = src.length;
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   789
        String[] dst = new String[len + 1];
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   790
        dst[0] = "";
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   791
        for (int i = 0; i < len; i++) {
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   792
            dst[i + 1] = src[i];
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   793
        }
7d8d9506b4ee 6991380: (cal) Calendar.cachedLocaleData should be transitioned from Hashtable to ConcurrentHashMap
okutsu
parents: 6497
diff changeset
   794
        return dst;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * Package private: used by SimpleDateFormat
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * Gets the index for the given time zone ID to obtain the time zone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * strings for formatting. The time zone ID is just for programmatic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * lookup. NOT LOCALIZED!!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * @param ID the given time zone ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * @return the index of the given time zone ID.  Returns -1 if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * the given time zone ID can't be located in the DateFormatSymbols object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @see java.util.SimpleTimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     */
12549
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   807
    final int getZoneIndex(String ID) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        String[][] zoneStrings = getZoneStringsWrapper();
12549
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   809
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   810
        /*
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   811
         * getZoneIndex has been re-written for performance reasons. instead of
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   812
         * traversing the zoneStrings array every time, we cache the last used zone
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   813
         * index
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   814
         */
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   815
        if (lastZoneIndex < zoneStrings.length && ID.equals(zoneStrings[lastZoneIndex][0])) {
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   816
            return lastZoneIndex;
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   817
        }
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   818
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   819
        /* slow path, search entire list */
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   820
        for (int index = 0; index < zoneStrings.length; index++) {
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   821
            if (ID.equals(zoneStrings[index][0])) {
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   822
                lastZoneIndex = index;
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   823
                return index;
db2c42dabfa4 7163865: Performance improvement for DateFormatSymbols.getZoneIndex(String)
youdwei
parents: 10419
diff changeset
   824
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * Wrapper method to the getZoneStrings(), which is called from inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * the java.text package and not to mutate the returned arrays, so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * it does not need to create a defensive copy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    final String[][] getZoneStringsWrapper() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        if (isSubclassObject()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
            return getZoneStrings();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            return getZoneStringsImpl(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   843
    private String[][] getZoneStringsImpl(boolean needsCopy) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        if (zoneStrings == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        if (!needsCopy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            return zoneStrings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        int len = zoneStrings.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        String[][] aCopy = new String[len][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            aCopy[i] = Arrays.copyOf(zoneStrings[i], zoneStrings[i].length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        return aCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 12549
diff changeset
   860
    private boolean isSubclassObject() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        return !getClass().getName().equals("java.text.DateFormatSymbols");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * Clones all the data members from the source DateFormatSymbols to
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   866
     * the target DateFormatSymbols.
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   867
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * @param src the source DateFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * @param dst the target DateFormatSymbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     */
36253
652d06266511 8151393: Revert changes for JDK-8087104
darcy
parents: 36241
diff changeset
   871
    private void copyMembers(DateFormatSymbols src, DateFormatSymbols dst)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    {
36951
0953f2a2cb14 8151431: DateFormatSymbols triggers this.clone() in the constructor
okutsu
parents: 36253
diff changeset
   873
        dst.locale = src.locale;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        dst.eras = Arrays.copyOf(src.eras, src.eras.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        dst.months = Arrays.copyOf(src.months, src.months.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        dst.shortMonths = Arrays.copyOf(src.shortMonths, src.shortMonths.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        dst.weekdays = Arrays.copyOf(src.weekdays, src.weekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        dst.shortWeekdays = Arrays.copyOf(src.shortWeekdays, src.shortWeekdays.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        dst.ampms = Arrays.copyOf(src.ampms, src.ampms.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        if (src.zoneStrings != null) {
36253
652d06266511 8151393: Revert changes for JDK-8087104
darcy
parents: 36241
diff changeset
   881
            dst.zoneStrings = src.getZoneStringsImpl(true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            dst.zoneStrings = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        }
6491
cd1bcc5057f4 4267450: (cal) API: Need public API to calculate, format and parse "year of week"
okutsu
parents: 6489
diff changeset
   885
        dst.localPatternChars = src.localPatternChars;
14172
fad44417edf8 7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
naoto
parents: 13583
diff changeset
   886
        dst.cachedHashCode = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     * Write out the default serializable data, after ensuring the
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   891
     * {@code zoneStrings} field is initialized in order to make
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * sure the backward compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     */
57956
e0b8b019d2f5 8229997: Apply java.io.Serial annotations in java.base
darcy
parents: 48660
diff changeset
   896
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    private void writeObject(ObjectOutputStream stream) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        if (zoneStrings == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        stream.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
}