Fields Summary |
---|
String[] | erasEra strings. For example: "AD" and "BC". An array of 2 strings,
indexed by Calendar.BC and Calendar.AD . |
String[] | monthsMonth strings. For example: "January", "February", etc. An array
of 13 strings (some calendars have 13 months), indexed by
Calendar.JANUARY , Calendar.FEBRUARY , etc. |
String[] | shortMonthsShort month strings. For example: "Jan", "Feb", etc. An array of
13 strings (some calendars have 13 months), indexed by
Calendar.JANUARY , Calendar.FEBRUARY , etc. |
String[] | weekdaysWeekday strings. For example: "Sunday", "Monday", etc. An array
of 8 strings, indexed by Calendar.SUNDAY ,
Calendar.MONDAY , etc.
The element weekdays[0] is ignored. |
String[] | shortWeekdaysShort weekday strings. For example: "Sun", "Mon", etc. An array
of 8 strings, indexed by Calendar.SUNDAY ,
Calendar.MONDAY , etc.
The element shortWeekdays[0] is ignored. |
String[] | ampmsAM and PM strings. For example: "AM" and "PM". An array of
2 strings, indexed by Calendar.AM and
Calendar.PM . |
String[] | zoneStringsLocalized names of time zones in this locale. This is a
two-dimensional array of strings of size n by m,
where m is at least 5. Each of the n rows is an
entry containing the localized names for a single TimeZone .
Each such row contains (with i ranging from
0..n-1):
zoneStrings[i][0] - time zone ID
zoneStrings[i][1] - long name of zone in standard
time
zoneStrings[i][2] - short name of zone in
standard time
zoneStrings[i][3] - long name of zone in daylight
saving time
zoneStrings[i][4] - short name of zone in daylight
saving time
The zone ID is not localized; it's one of the valid IDs of
the {@link java.util.TimeZone TimeZone} class that are not
custom IDs.
All other entries are localized names. |
transient boolean | isZoneStringsSetIndicates that zoneStrings is set externally with setZoneStrings() method. |
static final String | patternCharsUnlocalized date-time pattern characters. For example: 'y', 'd', etc.
All locales use the same these unlocalized pattern characters. |
String | localPatternCharsLocalized date-time pattern characters. For example, a locale may
wish to use 'u' rather than 'y' to represent years in its date format
pattern strings.
This string must be exactly 18 characters long, with the index of
the characters described by DateFormat.ERA_FIELD ,
DateFormat.YEAR_FIELD , etc. Thus, if the string were
"Xz...", then localized patterns would use 'X' for era and 'z' for year. |
Locale | localeThe locale which is used for initializing this DateFormatSymbols object. |
static final long | serialVersionUID |
static final int | millisPerHourUseful constant for defining time zone offsets. |
private static Hashtable | cachedLocaleDataCache to hold the FormatData and TimeZoneNames ResourceBundles
of a Locale. |
Methods Summary |
---|
private static java.util.ResourceBundle | cacheLookup(java.util.Locale desiredLocale)Look up resource data for the desiredLocale in the cache; update the
cache if necessary.
ResourceBundle rb;
SoftReference data
= (SoftReference)cachedLocaleData.get(desiredLocale);
if (data == null) {
rb = LocaleData.getDateFormatData(desiredLocale);
data = new SoftReference(rb);
cachedLocaleData.put(desiredLocale, data);
} else {
if ((rb = (ResourceBundle)data.get()) == null) {
rb = LocaleData.getDateFormatData(desiredLocale);
data = new SoftReference(rb);
}
}
return rb;
|
public java.lang.Object | clone()Overrides Cloneable
try
{
DateFormatSymbols other = (DateFormatSymbols)super.clone();
copyMembers(this, other);
return other;
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
|
private final void | copyMembers(java.text.DateFormatSymbols src, java.text.DateFormatSymbols dst)Clones all the data members from the source DateFormatSymbols to
the target DateFormatSymbols. This is only for subclasses.
dst.eras = duplicate(src.eras);
dst.months = duplicate(src.months);
dst.shortMonths = duplicate(src.shortMonths);
dst.weekdays = duplicate(src.weekdays);
dst.shortWeekdays = duplicate(src.shortWeekdays);
dst.ampms = duplicate(src.ampms);
if (src.zoneStrings != null) {
if (dst.zoneStrings == null) {
dst.zoneStrings = new String[src.zoneStrings.length][];
}
for (int i = 0; i < dst.zoneStrings.length; ++i) {
dst.zoneStrings[i] = duplicate(src.zoneStrings[i]);
}
} else {
dst.zoneStrings = null;
}
dst.localPatternChars = new String (src.localPatternChars);
|
private final java.lang.String[] | duplicate(java.lang.String[] srcArray)Clones an array of Strings.
String[] dstArray = new String[srcArray.length];
System.arraycopy(srcArray, 0, dstArray, 0, srcArray.length);
return dstArray;
|
public boolean | equals(java.lang.Object obj)Override equals
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
DateFormatSymbols that = (DateFormatSymbols) obj;
return (Arrays.equals(eras, that.eras)
&& Arrays.equals(months, that.months)
&& Arrays.equals(shortMonths, that.shortMonths)
&& Arrays.equals(weekdays, that.weekdays)
&& Arrays.equals(shortWeekdays, that.shortWeekdays)
&& Arrays.equals(ampms, that.ampms)
&& Arrays.deepEquals(getZoneStringsWrapper(), that.getZoneStringsWrapper())
&& ((localPatternChars != null
&& localPatternChars.equals(that.localPatternChars))
|| (localPatternChars == null
&& that.localPatternChars == null)));
|
private final boolean | equals(java.lang.String[] current, java.lang.String[] other)Compares the equality of the two arrays of String.
int count = current.length;
for (int i = 0; i < count; ++i)
if (!current[i].equals(other[i]))
return false;
return true;
|
public java.lang.String[] | getAmPmStrings()Gets ampm strings. For example: "AM" and "PM".
return duplicate(ampms);
|
public static java.util.Locale[] | getAvailableLocales()Returns an array of all locales for which the
getInstance methods of this class can return
localized instances.
The returned array represents the union of locales supported by the
Java runtime and by installed
{@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
implementations. It must contain at least a Locale
instance equal to {@link java.util.Locale#US Locale.US}.
LocaleServiceProviderPool pool=
LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
return pool.getAvailableLocales();
|
public java.lang.String[] | getEras()Gets era strings. For example: "AD" and "BC".
return duplicate(eras);
|
public static final java.text.DateFormatSymbols | getInstance()Gets the DateFormatSymbols instance for the default
locale. This method provides access to DateFormatSymbols
instances for locales supported by the Java runtime itself as well
as for those supported by installed
{@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
implementations.
return getInstance(Locale.getDefault());
|
public static final java.text.DateFormatSymbols | getInstance(java.util.Locale locale)Gets the DateFormatSymbols instance for the specified
locale. This method provides access to DateFormatSymbols
instances for locales supported by the Java runtime itself as well
as for those supported by installed
{@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
implementations.
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
if (pool.hasProviders()) {
DateFormatSymbols providersInstance = pool.getLocalizedObject(
DateFormatSymbolsGetter.INSTANCE, locale);
if (providersInstance != null) {
return providersInstance;
}
}
return new DateFormatSymbols(locale);
|
public java.lang.String | getLocalPatternChars()Gets localized date-time pattern characters. For example: 'u', 't', etc.
return new String(localPatternChars);
|
public java.lang.String[] | getMonths()Gets month strings. For example: "January", "February", etc.
return duplicate(months);
|
public java.lang.String[] | getShortMonths()Gets short month strings. For example: "Jan", "Feb", etc.
return duplicate(shortMonths);
|
public java.lang.String[] | getShortWeekdays()Gets short weekday strings. For example: "Sun", "Mon", etc.
return duplicate(shortWeekdays);
|
public java.lang.String[] | getWeekdays()Gets weekday strings. For example: "Sunday", "Monday", etc.
return duplicate(weekdays);
|
final int | getZoneIndex(java.lang.String ID)Package private: used by SimpleDateFormat
Gets the index for the given time zone ID to obtain the time zone
strings for formatting. The time zone ID is just for programmatic
lookup. NOT LOCALIZED!!!
String[][] zoneStrings = getZoneStringsWrapper();
for (int index=0; index<zoneStrings.length; index++)
{
if (ID.equalsIgnoreCase(zoneStrings[index][0])) return index;
}
return -1;
|
public java.lang.String[][] | getZoneStrings()Gets time zone strings. Use of this method is discouraged; use
{@link java.util.TimeZone#getDisplayName() TimeZone.getDisplayName()}
instead.
The value returned is a
two-dimensional array of strings of size n by m,
where m is at least 5. Each of the n rows is an
entry containing the localized names for a single TimeZone .
Each such row contains (with i ranging from
0..n-1):
zoneStrings[i][0] - time zone ID
zoneStrings[i][1] - long name of zone in standard
time
zoneStrings[i][2] - short name of zone in
standard time
zoneStrings[i][3] - long name of zone in daylight
saving time
zoneStrings[i][4] - short name of zone in daylight
saving time
The zone ID is not localized; it's one of the valid IDs of
the {@link java.util.TimeZone TimeZone} class that are not
custom IDs.
All other entries are localized names. If a zone does not implement
daylight saving time, the daylight saving time names should not be used.
If {@link #setZoneStrings(String[][]) setZoneStrings} has been called
on this DateFormatSymbols instance, then the strings
provided by that call are returned. Otherwise, the returned array
contains names provided by the Java runtime and by installed
{@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider}
implementations.
return getZoneStringsImpl(true);
|
private final java.lang.String[][] | getZoneStringsImpl(boolean needsCopy)
if (zoneStrings == null) {
zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
}
if (needsCopy) {
String[][] aCopy = new String[zoneStrings.length][];
for (int i = 0; i < zoneStrings.length; ++i) {
aCopy[i] = duplicate(zoneStrings[i]);
}
return aCopy;
} else {
return zoneStrings;
}
|
final java.lang.String[][] | getZoneStringsWrapper()Wrapper method to the getZoneStrings(), which is called from inside
the java.text package and not to mutate the returned arrays, so that
it does not need to create a defensive copy.
if (isSubclassObject()) {
return getZoneStrings();
} else {
return getZoneStringsImpl(false);
}
|
public int | hashCode()Override hashCode.
Generates a hash code for the DateFormatSymbols object.
int hashcode = 0;
String[][] zoneStrings = getZoneStringsWrapper();
for (int index = 0; index < zoneStrings[0].length; ++index)
hashcode ^= zoneStrings[0][index].hashCode();
return hashcode;
|
private void | initializeData(java.util.Locale desiredLocale)
int i;
ResourceBundle resource = cacheLookup(desiredLocale);
// FIXME: cache only ResourceBundle. Hence every time, will do
// getObject(). This won't be necessary if the Resource itself
// is cached.
eras = (String[])resource.getObject("Eras");
months = resource.getStringArray("MonthNames");
shortMonths = resource.getStringArray("MonthAbbreviations");
String[] lWeekdays = resource.getStringArray("DayNames");
weekdays = new String[8];
weekdays[0] = ""; // 1-based
for (i=0; i<lWeekdays.length; i++)
weekdays[i+1] = lWeekdays[i];
String[] sWeekdays = resource.getStringArray("DayAbbreviations");
shortWeekdays = new String[8];
shortWeekdays[0] = ""; // 1-based
for (i=0; i<sWeekdays.length; i++)
shortWeekdays[i+1] = sWeekdays[i];
ampms = resource.getStringArray("AmPmMarkers");
localPatternChars = resource.getString("DateTimePatternChars");
locale = desiredLocale;
|
private final boolean | isSubclassObject()
return !getClass().getName().equals("java.text.DateFormatSymbols");
|
public void | setAmPmStrings(java.lang.String[] newAmpms)Sets ampm strings. For example: "AM" and "PM".
ampms = duplicate(newAmpms);
|
public void | setEras(java.lang.String[] newEras)Sets era strings. For example: "AD" and "BC".
eras = duplicate(newEras);
|
public void | setLocalPatternChars(java.lang.String newLocalPatternChars)Sets localized date-time pattern characters. For example: 'u', 't', etc.
localPatternChars = new String(newLocalPatternChars);
|
public void | setMonths(java.lang.String[] newMonths)Sets month strings. For example: "January", "February", etc.
months = duplicate(newMonths);
|
public void | setShortMonths(java.lang.String[] newShortMonths)Sets short month strings. For example: "Jan", "Feb", etc.
shortMonths = duplicate(newShortMonths);
|
public void | setShortWeekdays(java.lang.String[] newShortWeekdays)Sets short weekday strings. For example: "Sun", "Mon", etc.
shortWeekdays = duplicate(newShortWeekdays);
|
public void | setWeekdays(java.lang.String[] newWeekdays)Sets weekday strings. For example: "Sunday", "Monday", etc.
weekdays = duplicate(newWeekdays);
|
public void | setZoneStrings(java.lang.String[][] newZoneStrings)Sets time zone strings. The argument must be a
two-dimensional array of strings of size n by m,
where m is at least 5. Each of the n rows is an
entry containing the localized names for a single TimeZone .
Each such row contains (with i ranging from
0..n-1):
zoneStrings[i][0] - time zone ID
zoneStrings[i][1] - long name of zone in standard
time
zoneStrings[i][2] - short name of zone in
standard time
zoneStrings[i][3] - long name of zone in daylight
saving time
zoneStrings[i][4] - short name of zone in daylight
saving time
The zone ID is not localized; it's one of the valid IDs of
the {@link java.util.TimeZone TimeZone} class that are not
custom IDs.
All other entries are localized names.
String[][] aCopy = new String[newZoneStrings.length][];
for (int i = 0; i < newZoneStrings.length; ++i) {
if (newZoneStrings[i].length < 5) {
throw new IllegalArgumentException();
}
aCopy[i] = duplicate(newZoneStrings[i]);
}
zoneStrings = aCopy;
isZoneStringsSet = true;
|
private void | writeObject(java.io.ObjectOutputStream stream)Write out the default serializable data, after ensuring the
zoneStrings field is initialized in order to make
sure the backward compatibility.
if (zoneStrings == null) {
zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
}
stream.defaultWriteObject();
|