2 * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
27 * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
28 * (C) Copyright IBM Corp. 1996 - All Rights Reserved
30 * The original version of this source code and documentation is copyrighted
31 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
32 * materials are provided under terms of a License Agreement between Taligent
33 * and Sun. This technology is protected by multiple US and International
34 * patents. This notice and attribution to Taligent may not be removed.
35 * Taligent is a registered trademark of Taligent, Inc.
41 import java.io.IOException;
42 import java.io.ObjectOutputStream;
43 import java.io.Serializable;
44 import java.lang.ref.SoftReference;
45 import java.util.Arrays;
46 import java.util.Locale;
47 import java.util.ResourceBundle;
48 import java.util.concurrent.ConcurrentHashMap;
49 import java.util.concurrent.ConcurrentMap;
52 * <code>DateFormatSymbols</code> is a public class for encapsulating
53 * localizable date-time formatting data, such as the names of the
54 * months, the names of the days of the week, and the time zone data.
55 * <code>DateFormat</code> and <code>SimpleDateFormat</code> both use
56 * <code>DateFormatSymbols</code> to encapsulate this information.
59 * Typically you shouldn't use <code>DateFormatSymbols</code> directly.
60 * Rather, you are encouraged to create a date-time formatter with the
61 * <code>DateFormat</code> class's factory methods: <code>getTimeInstance</code>,
62 * <code>getDateInstance</code>, or <code>getDateTimeInstance</code>.
63 * These methods automatically create a <code>DateFormatSymbols</code> for
64 * the formatter so that you don't have to. After the
65 * formatter is created, you may modify its format pattern using the
66 * <code>setPattern</code> method. For more information about
67 * creating formatters using <code>DateFormat</code>'s factory methods,
68 * see {@link DateFormat}.
71 * If you decide to create a date-time formatter with a specific
72 * format pattern for a specific locale, you can do so with:
75 * new SimpleDateFormat(aPattern, DateFormatSymbols.getInstance(aLocale)).
80 * <code>DateFormatSymbols</code> objects are cloneable. When you obtain
81 * a <code>DateFormatSymbols</code> object, feel free to modify the
82 * date-time formatting data. For instance, you can replace the localized
83 * date-time format pattern characters with the ones that you feel easy
84 * to remember. Or you can change the representative cities
85 * to your favorite ones.
88 * New <code>DateFormatSymbols</code> subclasses may be added to support
89 * <code>SimpleDateFormat</code> for date-time formatting for additional locales.
92 * @see SimpleDateFormat
93 * @see java.util.SimpleTimeZone
94 * @author Chen-Lieh Huang
96 public class DateFormatSymbols implements Serializable, Cloneable {
99 * Construct a DateFormatSymbols object by loading format data from
100 * resources for the default locale. This constructor can only
101 * construct instances for the locales supported by the Java
102 * runtime environment, not for those supported by installed
103 * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
104 * implementations. For full locale coverage, use the
105 * {@link #getInstance(Locale) getInstance} method.
107 * @see #getInstance()
108 * @exception java.util.MissingResourceException
109 * if the resources for the default locale cannot be
110 * found or cannot be loaded.
112 public DateFormatSymbols()
114 initializeData(Locale.getDefault(Locale.Category.FORMAT));
118 * Construct a DateFormatSymbols object by loading format data from
119 * resources for the given locale. This constructor can only
120 * construct instances for the locales supported by the Java
121 * runtime environment, not for those supported by installed
122 * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
123 * implementations. For full locale coverage, use the
124 * {@link #getInstance(Locale) getInstance} method.
126 * @see #getInstance(Locale)
127 * @exception java.util.MissingResourceException
128 * if the resources for the specified locale cannot be
129 * found or cannot be loaded.
131 public DateFormatSymbols(Locale locale)
133 initializeData(locale);
137 * Era strings. For example: "AD" and "BC". An array of 2 strings,
138 * indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
141 String eras[] = null;
144 * Month strings. For example: "January", "February", etc. An array
145 * of 13 strings (some calendars have 13 months), indexed by
146 * <code>Calendar.JANUARY</code>, <code>Calendar.FEBRUARY</code>, etc.
149 String months[] = null;
152 * Short month strings. For example: "Jan", "Feb", etc. An array of
153 * 13 strings (some calendars have 13 months), indexed by
154 * <code>Calendar.JANUARY</code>, <code>Calendar.FEBRUARY</code>, etc.
158 String shortMonths[] = null;
161 * Weekday strings. For example: "Sunday", "Monday", etc. An array
162 * of 8 strings, indexed by <code>Calendar.SUNDAY</code>,
163 * <code>Calendar.MONDAY</code>, etc.
164 * The element <code>weekdays[0]</code> is ignored.
167 String weekdays[] = null;
170 * Short weekday strings. For example: "Sun", "Mon", etc. An array
171 * of 8 strings, indexed by <code>Calendar.SUNDAY</code>,
172 * <code>Calendar.MONDAY</code>, etc.
173 * The element <code>shortWeekdays[0]</code> is ignored.
176 String shortWeekdays[] = null;
179 * AM and PM strings. For example: "AM" and "PM". An array of
180 * 2 strings, indexed by <code>Calendar.AM</code> and
181 * <code>Calendar.PM</code>.
184 String ampms[] = null;
187 * Localized names of time zones in this locale. This is a
188 * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
189 * where <em>m</em> is at least 5. Each of the <em>n</em> rows is an
190 * entry containing the localized names for a single <code>TimeZone</code>.
191 * Each such row contains (with <code>i</code> ranging from
194 * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
195 * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
197 * <li><code>zoneStrings[i][2]</code> - short name of zone in
199 * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
201 * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
204 * The zone ID is <em>not</em> localized; it's one of the valid IDs of
205 * the {@link java.util.TimeZone TimeZone} class that are not
206 * <a href="../java/util/TimeZone.html#CustomID">custom IDs</a>.
207 * All other entries are localized names.
208 * @see java.util.TimeZone
211 String zoneStrings[][] = null;
214 * Indicates that zoneStrings is set externally with setZoneStrings() method.
216 transient boolean isZoneStringsSet = false;
219 * Unlocalized date-time pattern characters. For example: 'y', 'd', etc.
220 * All locales use the same these unlocalized pattern characters.
222 static final String patternChars = "GyMdkHmsSEDFwWahKzZYuX";
224 static final int PATTERN_ERA = 0; // G
225 static final int PATTERN_YEAR = 1; // y
226 static final int PATTERN_MONTH = 2; // M
227 static final int PATTERN_DAY_OF_MONTH = 3; // d
228 static final int PATTERN_HOUR_OF_DAY1 = 4; // k
229 static final int PATTERN_HOUR_OF_DAY0 = 5; // H
230 static final int PATTERN_MINUTE = 6; // m
231 static final int PATTERN_SECOND = 7; // s
232 static final int PATTERN_MILLISECOND = 8; // S
233 static final int PATTERN_DAY_OF_WEEK = 9; // E
234 static final int PATTERN_DAY_OF_YEAR = 10; // D
235 static final int PATTERN_DAY_OF_WEEK_IN_MONTH = 11; // F
236 static final int PATTERN_WEEK_OF_YEAR = 12; // w
237 static final int PATTERN_WEEK_OF_MONTH = 13; // W
238 static final int PATTERN_AM_PM = 14; // a
239 static final int PATTERN_HOUR1 = 15; // h
240 static final int PATTERN_HOUR0 = 16; // K
241 static final int PATTERN_ZONE_NAME = 17; // z
242 static final int PATTERN_ZONE_VALUE = 18; // Z
243 static final int PATTERN_WEEK_YEAR = 19; // Y
244 static final int PATTERN_ISO_DAY_OF_WEEK = 20; // u
245 static final int PATTERN_ISO_ZONE = 21; // X
248 * Localized date-time pattern characters. For example, a locale may
249 * wish to use 'u' rather than 'y' to represent years in its date format
251 * This string must be exactly 18 characters long, with the index of
252 * the characters described by <code>DateFormat.ERA_FIELD</code>,
253 * <code>DateFormat.YEAR_FIELD</code>, etc. Thus, if the string were
254 * "Xz...", then localized patterns would use 'X' for era and 'z' for year.
257 String localPatternChars = null;
260 * The locale which is used for initializing this DateFormatSymbols object.
265 Locale locale = null;
267 /* use serialVersionUID from JDK 1.1.4 for interoperability */
268 static final long serialVersionUID = -5987973545549424702L;
271 * Returns an array of all locales for which the
272 * <code>getInstance</code> methods of this class can return
273 * localized instances.
274 * The returned array represents the union of locales supported by the
275 * Java runtime and by installed
276 * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
277 * implementations. It must contain at least a <code>Locale</code>
278 * instance equal to {@link java.util.Locale#US Locale.US}.
280 * @return An array of locales for which localized
281 * <code>DateFormatSymbols</code> instances are available.
284 public static Locale[] getAvailableLocales() {
285 return new Locale[] { Locale.US };
286 // LocaleServiceProviderPool pool=
287 // LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
288 // return pool.getAvailableLocales();
292 * Gets the <code>DateFormatSymbols</code> instance for the default
293 * locale. This method provides access to <code>DateFormatSymbols</code>
294 * instances for locales supported by the Java runtime itself as well
295 * as for those supported by installed
296 * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
298 * @return a <code>DateFormatSymbols</code> instance.
301 public static final DateFormatSymbols getInstance() {
302 return getInstance(Locale.getDefault(Locale.Category.FORMAT));
306 * Gets the <code>DateFormatSymbols</code> instance for the specified
307 * locale. This method provides access to <code>DateFormatSymbols</code>
308 * instances for locales supported by the Java runtime itself as well
309 * as for those supported by installed
310 * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
312 * @param locale the given locale.
313 * @return a <code>DateFormatSymbols</code> instance.
314 * @exception NullPointerException if <code>locale</code> is null
317 public static final DateFormatSymbols getInstance(Locale locale) {
318 DateFormatSymbols dfs = getProviderInstance(locale);
322 return (DateFormatSymbols) getCachedInstance(locale).clone();
326 * Returns a DateFormatSymbols provided by a provider or found in
327 * the cache. Note that this method returns a cached instance,
328 * not its clone. Therefore, the instance should never be given to
331 static final DateFormatSymbols getInstanceRef(Locale locale) {
332 DateFormatSymbols dfs = getProviderInstance(locale);
336 return getCachedInstance(locale);
339 private static DateFormatSymbols getProviderInstance(Locale locale) {
340 DateFormatSymbols providersInstance = null;
342 // Check whether a provider can provide an implementation that's closer
343 // to the requested locale than what the Java runtime itself can provide.
344 // LocaleServiceProviderPool pool =
345 // LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
346 // if (pool.hasProviders()) {
347 // providersInstance = pool.getLocalizedObject(
348 // DateFormatSymbolsGetter.INSTANCE, locale);
350 return providersInstance;
354 * Returns a cached DateFormatSymbols if it's found in the
355 * cache. Otherwise, this method returns a newly cached instance
356 * for the given locale.
358 private static DateFormatSymbols getCachedInstance(Locale locale) {
359 SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
360 DateFormatSymbols dfs = null;
361 if (ref == null || (dfs = ref.get()) == null) {
362 dfs = new DateFormatSymbols(locale);
363 ref = new SoftReference<DateFormatSymbols>(dfs);
364 SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
366 DateFormatSymbols y = x.get();
370 // Replace the empty SoftReference with ref.
371 cachedInstances.put(locale, ref);
379 * Gets era strings. For example: "AD" and "BC".
380 * @return the era strings.
382 public String[] getEras() {
383 return Arrays.copyOf(eras, eras.length);
387 * Sets era strings. For example: "AD" and "BC".
388 * @param newEras the new era strings.
390 public void setEras(String[] newEras) {
391 eras = Arrays.copyOf(newEras, newEras.length);
395 * Gets month strings. For example: "January", "February", etc.
396 * @return the month strings.
398 public String[] getMonths() {
399 return Arrays.copyOf(months, months.length);
403 * Sets month strings. For example: "January", "February", etc.
404 * @param newMonths the new month strings.
406 public void setMonths(String[] newMonths) {
407 months = Arrays.copyOf(newMonths, newMonths.length);
411 * Gets short month strings. For example: "Jan", "Feb", etc.
412 * @return the short month strings.
414 public String[] getShortMonths() {
415 return Arrays.copyOf(shortMonths, shortMonths.length);
419 * Sets short month strings. For example: "Jan", "Feb", etc.
420 * @param newShortMonths the new short month strings.
422 public void setShortMonths(String[] newShortMonths) {
423 shortMonths = Arrays.copyOf(newShortMonths, newShortMonths.length);
427 * Gets weekday strings. For example: "Sunday", "Monday", etc.
428 * @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
429 * <code>Calendar.MONDAY</code>, etc. to index the result array.
431 public String[] getWeekdays() {
432 return Arrays.copyOf(weekdays, weekdays.length);
436 * Sets weekday strings. For example: "Sunday", "Monday", etc.
437 * @param newWeekdays the new weekday strings. The array should
438 * be indexed by <code>Calendar.SUNDAY</code>,
439 * <code>Calendar.MONDAY</code>, etc.
441 public void setWeekdays(String[] newWeekdays) {
442 weekdays = Arrays.copyOf(newWeekdays, newWeekdays.length);
446 * Gets short weekday strings. For example: "Sun", "Mon", etc.
447 * @return the short weekday strings. Use <code>Calendar.SUNDAY</code>,
448 * <code>Calendar.MONDAY</code>, etc. to index the result array.
450 public String[] getShortWeekdays() {
451 return Arrays.copyOf(shortWeekdays, shortWeekdays.length);
455 * Sets short weekday strings. For example: "Sun", "Mon", etc.
456 * @param newShortWeekdays the new short weekday strings. The array should
457 * be indexed by <code>Calendar.SUNDAY</code>,
458 * <code>Calendar.MONDAY</code>, etc.
460 public void setShortWeekdays(String[] newShortWeekdays) {
461 shortWeekdays = Arrays.copyOf(newShortWeekdays, newShortWeekdays.length);
465 * Gets ampm strings. For example: "AM" and "PM".
466 * @return the ampm strings.
468 public String[] getAmPmStrings() {
469 return Arrays.copyOf(ampms, ampms.length);
473 * Sets ampm strings. For example: "AM" and "PM".
474 * @param newAmpms the new ampm strings.
476 public void setAmPmStrings(String[] newAmpms) {
477 ampms = Arrays.copyOf(newAmpms, newAmpms.length);
481 * Gets time zone strings. Use of this method is discouraged; use
482 * {@link java.util.TimeZone#getDisplayName() TimeZone.getDisplayName()}
485 * The value returned is a
486 * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
487 * where <em>m</em> is at least 5. Each of the <em>n</em> rows is an
488 * entry containing the localized names for a single <code>TimeZone</code>.
489 * Each such row contains (with <code>i</code> ranging from
492 * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
493 * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
495 * <li><code>zoneStrings[i][2]</code> - short name of zone in
497 * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
499 * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
502 * The zone ID is <em>not</em> localized; it's one of the valid IDs of
503 * the {@link java.util.TimeZone TimeZone} class that are not
504 * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
505 * All other entries are localized names. If a zone does not implement
506 * daylight saving time, the daylight saving time names should not be used.
508 * If {@link #setZoneStrings(String[][]) setZoneStrings} has been called
509 * on this <code>DateFormatSymbols</code> instance, then the strings
510 * provided by that call are returned. Otherwise, the returned array
511 * contains names provided by the Java runtime and by installed
512 * {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider}
515 * @return the time zone strings.
516 * @see #setZoneStrings(String[][])
518 public String[][] getZoneStrings() {
519 return getZoneStringsImpl(true);
523 * Sets time zone strings. The argument must be a
524 * two-dimensional array of strings of size <em>n</em> by <em>m</em>,
525 * where <em>m</em> is at least 5. Each of the <em>n</em> rows is an
526 * entry containing the localized names for a single <code>TimeZone</code>.
527 * Each such row contains (with <code>i</code> ranging from
530 * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
531 * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
533 * <li><code>zoneStrings[i][2]</code> - short name of zone in
535 * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
537 * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
540 * The zone ID is <em>not</em> localized; it's one of the valid IDs of
541 * the {@link java.util.TimeZone TimeZone} class that are not
542 * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
543 * All other entries are localized names.
545 * @param newZoneStrings the new time zone strings.
546 * @exception IllegalArgumentException if the length of any row in
547 * <code>newZoneStrings</code> is less than 5
548 * @exception NullPointerException if <code>newZoneStrings</code> is null
549 * @see #getZoneStrings()
551 public void setZoneStrings(String[][] newZoneStrings) {
552 String[][] aCopy = new String[newZoneStrings.length][];
553 for (int i = 0; i < newZoneStrings.length; ++i) {
554 int len = newZoneStrings[i].length;
556 throw new IllegalArgumentException();
558 aCopy[i] = Arrays.copyOf(newZoneStrings[i], len);
561 isZoneStringsSet = true;
565 * Gets localized date-time pattern characters. For example: 'u', 't', etc.
566 * @return the localized date-time pattern characters.
568 public String getLocalPatternChars() {
569 return localPatternChars;
573 * Sets localized date-time pattern characters. For example: 'u', 't', etc.
574 * @param newLocalPatternChars the new localized date-time
575 * pattern characters.
577 public void setLocalPatternChars(String newLocalPatternChars) {
578 // Call toString() to throw an NPE in case the argument is null
579 localPatternChars = newLocalPatternChars.toString();
583 * Overrides Cloneable
585 public Object clone()
589 DateFormatSymbols other = (DateFormatSymbols)super.clone();
590 copyMembers(this, other);
592 } catch (CloneNotSupportedException e) {
593 throw new InternalError();
599 * Generates a hash code for the DateFormatSymbols object.
601 public int hashCode() {
603 String[][] zoneStrings = getZoneStringsWrapper();
604 for (int index = 0; index < zoneStrings[0].length; ++index)
605 hashcode ^= zoneStrings[0][index].hashCode();
612 public boolean equals(Object obj)
614 if (this == obj) return true;
615 if (obj == null || getClass() != obj.getClass()) return false;
616 DateFormatSymbols that = (DateFormatSymbols) obj;
617 return (Arrays.equals(eras, that.eras)
618 && Arrays.equals(months, that.months)
619 && Arrays.equals(shortMonths, that.shortMonths)
620 && Arrays.equals(weekdays, that.weekdays)
621 && Arrays.equals(shortWeekdays, that.shortWeekdays)
622 && Arrays.equals(ampms, that.ampms)
623 && Arrays.deepEquals(getZoneStringsWrapper(), that.getZoneStringsWrapper())
624 && ((localPatternChars != null
625 && localPatternChars.equals(that.localPatternChars))
626 || (localPatternChars == null
627 && that.localPatternChars == null)));
630 // =======================privates===============================
633 * Useful constant for defining time zone offsets.
635 static final int millisPerHour = 60*60*1000;
638 * Cache to hold DateFormatSymbols instances per Locale.
640 private static final ConcurrentMap<Locale, SoftReference<DateFormatSymbols>> cachedInstances
641 = new ConcurrentHashMap<Locale, SoftReference<DateFormatSymbols>>(3);
643 private void initializeData(Locale desiredLocale) {
644 locale = desiredLocale;
646 // Copy values of a cached instance if any.
647 SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
648 DateFormatSymbols dfs;
649 if (ref != null && (dfs = ref.get()) != null) {
650 copyMembers(dfs, this);
654 // Initialize the fields from the ResourceBundle for locale.
655 // ResourceBundle resource = LocaleData.getDateFormatData(locale);
657 // eras = resource.getStringArray("Eras");
658 // months = resource.getStringArray("MonthNames");
659 // shortMonths = resource.getStringArray("MonthAbbreviations");
660 // ampms = resource.getStringArray("AmPmMarkers");
661 // localPatternChars = resource.getString("DateTimePatternChars");
663 // // Day of week names are stored in a 1-based array.
664 // weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
665 // shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));
668 private static String[] toOneBasedArray(String[] src) {
669 int len = src.length;
670 String[] dst = new String[len + 1];
672 for (int i = 0; i < len; i++) {
679 * Package private: used by SimpleDateFormat
680 * Gets the index for the given time zone ID to obtain the time zone
681 * strings for formatting. The time zone ID is just for programmatic
682 * lookup. NOT LOCALIZED!!!
683 * @param ID the given time zone ID.
684 * @return the index of the given time zone ID. Returns -1 if
685 * the given time zone ID can't be located in the DateFormatSymbols object.
686 * @see java.util.SimpleTimeZone
688 final int getZoneIndex(String ID)
690 String[][] zoneStrings = getZoneStringsWrapper();
691 for (int index=0; index<zoneStrings.length; index++)
693 if (ID.equals(zoneStrings[index][0])) return index;
700 * Wrapper method to the getZoneStrings(), which is called from inside
701 * the java.text package and not to mutate the returned arrays, so that
702 * it does not need to create a defensive copy.
704 final String[][] getZoneStringsWrapper() {
705 if (isSubclassObject()) {
706 return getZoneStrings();
708 return getZoneStringsImpl(false);
712 private final String[][] getZoneStringsImpl(boolean needsCopy) {
713 if (zoneStrings == null) {
714 // zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
721 int len = zoneStrings.length;
722 String[][] aCopy = new String[len][];
723 for (int i = 0; i < len; i++) {
724 aCopy[i] = Arrays.copyOf(zoneStrings[i], zoneStrings[i].length);
729 private final boolean isSubclassObject() {
730 return !getClass().getName().equals("java.text.DateFormatSymbols");
734 * Clones all the data members from the source DateFormatSymbols to
735 * the target DateFormatSymbols. This is only for subclasses.
736 * @param src the source DateFormatSymbols.
737 * @param dst the target DateFormatSymbols.
739 private final void copyMembers(DateFormatSymbols src, DateFormatSymbols dst)
741 dst.eras = Arrays.copyOf(src.eras, src.eras.length);
742 dst.months = Arrays.copyOf(src.months, src.months.length);
743 dst.shortMonths = Arrays.copyOf(src.shortMonths, src.shortMonths.length);
744 dst.weekdays = Arrays.copyOf(src.weekdays, src.weekdays.length);
745 dst.shortWeekdays = Arrays.copyOf(src.shortWeekdays, src.shortWeekdays.length);
746 dst.ampms = Arrays.copyOf(src.ampms, src.ampms.length);
747 if (src.zoneStrings != null) {
748 dst.zoneStrings = src.getZoneStringsImpl(true);
750 dst.zoneStrings = null;
752 dst.localPatternChars = src.localPatternChars;
756 * Write out the default serializable data, after ensuring the
757 * <code>zoneStrings</code> field is initialized in order to make
758 * sure the backward compatibility.
761 private void writeObject(ObjectOutputStream stream) throws IOException {
762 if (zoneStrings == null) {
763 zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
765 stream.defaultWriteObject();
769 * Obtains a DateFormatSymbols instance from a DateFormatSymbolsProvider
771 private static class DateFormatSymbolsGetter
772 implements LocaleServiceProviderPool.LocalizedObjectGetter<DateFormatSymbolsProvider,
774 private static final DateFormatSymbolsGetter INSTANCE =
775 new DateFormatSymbolsGetter();
777 public DateFormatSymbols getObject(DateFormatSymbolsProvider dateFormatSymbolsProvider,
781 assert params.length == 0;
782 return dateFormatSymbolsProvider.getInstance(locale);