DateFormatSymbols is a public class for encapsulating
localizable date-time formatting data, such as the names of the
months, the names of the days of the week, and the time zone data.
SimpleDateFormat uses
DateFormatSymbols to encapsulate this information.
Typically you shouldn't use DateFormatSymbols directly.
Rather, you are encouraged to create a date-time formatter with the
DateFormat class's factory methods: getTimeInstance,
getDateInstance, or getDateTimeInstance.
These methods automatically create a DateFormatSymbols for
the formatter so that you don't have to. After the
formatter is created, you may modify its format pattern using the
setPattern method. For more information about
creating formatters using DateFormat's factory methods,
see DateFormat.
If you decide to create a date-time formatter with a specific format pattern for a specific locale, you can do so with:
new SimpleDateFormat(aPattern, DateFormatSymbols.getInstance(aLocale));
If the locale contains "rg" (region override) Unicode extension, the symbols are overridden for the designated region.
DateFormatSymbols objects are cloneable. When you obtain
a DateFormatSymbols object, feel free to modify the
date-time formatting data. For instance, you can replace the localized
date-time format pattern characters with the ones that you feel easy
to remember. Or you can change the representative cities
to your favorite ones.
New DateFormatSymbols subclasses may be added to support
SimpleDateFormat for date-time formatting for additional locales.
DateFormat, SimpleDateFormat, java.util.SimpleTimeZone
| Modifier and Type | Field and Description |
|---|---|
| pack-priv String[] | ampms
AM and PM strings. |
| pack-priv transient volatile int | cachedHashCode
Cached hash code |
| private static final ConcurrentMap | cachedInstances
Cache to hold DateFormatSymbols instances per Locale. |
| pack-priv String[] | eras
Era strings. |
| pack-priv transient boolean | isZoneStringsSet
Indicates that zoneStrings is set externally with setZoneStrings() method. |
| private transient int | |
| pack-priv Locale | locale
The locale which is used for initializing this DateFormatSymbols object. |
| pack-priv String | localPatternChars
Localized date-time pattern characters. |
| pack-priv String[] | months
Month strings. |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final String | patternChars
Unlocalized date-time pattern characters. |
| pack-priv static final long | |
| pack-priv String[] | shortMonths
Short month strings. |
| pack-priv String[] | shortWeekdays
Short weekday strings. |
| pack-priv String[] | weekdays
Weekday strings. |
| pack-priv String[][] | zoneStrings
Localized names of time zones in this locale. |
| Access | Constructor and Description |
|---|---|
| public | DateFormatSymbols()
Construct a DateFormatSymbols object by loading format data from
resources for the default |
| public | DateFormatSymbols(Locale
the desired locale locale)Construct a DateFormatSymbols object by loading format data from resources for the given locale. |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Object | |
| private void | copyMembers(DateFormatSymbols
the source DateFormatSymbols. src, DateFormatSymbols the target DateFormatSymbols. dst)Clones all the data members from the source DateFormatSymbols to the target DateFormatSymbols. |
| public boolean | Returns: true if the specified object is equal to this DateFormatSymbolsobject to be compared for equality obj)Overrides java. Compares the specified object with this |
| public String[] | |
| public static Locale[] | Returns: An array of locales for which localizedDateFormatSymbols instances are available.Returns an array of all locales for which the
|
| public String[] | |
| public static final DateFormatSymbols | Returns: aDateFormatSymbols instance.Gets the |
| public static final DateFormatSymbols | Returns: aDateFormatSymbols instance.the given locale. locale)Gets the |
| public String | Returns: the localized date-time pattern characters.Gets localized date-time pattern characters. |
| public String[] | |
| private static DateFormatSymbols | |
| public String[] | |
| public String[] | Returns: the short weekday strings. UseCalendar.,
Calendar., etc. to index
the result array.Gets short weekday strings. |
| public String[] | |
| pack-priv final int | Returns: the index of the given time zone ID. Returns -1 if the given time zone ID can't be located in the DateFormatSymbols object.the given time zone ID. ID)Package private: used by SimpleDateFormat Gets the index for the given time zone ID to obtain the time zone strings for formatting. |
| public String[][] | |
| private String[][] | |
| pack-priv final 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. |
| public int | Returns: the hash code for thisDateFormatSymbolsOverrides java. Returns the hash code for this |
| private void | |
| private boolean | |
| public void | |
| public void | |
| public void | setLocalPatternChars(String
the new localized date-time
pattern characters. newLocalPatternChars)Sets localized date-time pattern characters. |
| public void | setMonths(String[]
the new month strings. The array should
be indexed by newMonths)Calendar.,
Calendar., etc.Sets month strings. |
| public void | setShortMonths(String[]
the new short month strings. The array should
be indexed by newShortMonths)Calendar.,
Calendar., etc.Sets short month strings. |
| public void | setShortWeekdays(String[]
the new short weekday strings. The array should
be indexed by newShortWeekdays)Calendar.,
Calendar., etc.Sets short weekday strings. |
| public void | setWeekdays(String[]
the new weekday strings. The array should
be indexed by newWeekdays)Calendar.,
Calendar., etc.Sets weekday strings. |
| public void | |
| private static String[] | |
| private void | writeObject(ObjectOutputStream stream)
Write out the default serializable data, after ensuring the
|
| ampms | back to summary |
|---|---|
| pack-priv String[] ampms AM and PM strings. For example: "AM" and "PM". An array of
2 strings, indexed by | |
| cachedHashCode | back to summary |
|---|---|
| pack-priv transient volatile int cachedHashCode Cached hash code | |
| cachedInstances | back to summary |
|---|---|
| private static final ConcurrentMap<Locale, SoftReference<DateFormatSymbols>> cachedInstances Cache to hold DateFormatSymbols instances per Locale. | |
| eras | back to summary |
|---|---|
| pack-priv String[] eras Era strings. For example: "AD" and "BC". An array of 2 strings,
indexed by | |
| isZoneStringsSet | back to summary |
|---|---|
| pack-priv transient boolean isZoneStringsSet Indicates that zoneStrings is set externally with setZoneStrings() method. | |
| lastZoneIndex | back to summary |
|---|---|
| private transient int lastZoneIndex | |
| locale | back to summary |
|---|---|
| pack-priv Locale locale The locale which is used for initializing this DateFormatSymbols object.
| |
| localPatternChars | back to summary |
|---|---|
| pack-priv String localPatternChars Localized 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 | |
| months | back to summary |
|---|---|
| pack-priv String[] months Month strings. For example: "January", "February", etc. An array
of 13 strings (some calendars have 13 months), indexed by
| |
| PATTERN_AM_PM | back to summary |
|---|---|
| pack-priv static final int PATTERN_AM_PM | |
| PATTERN_DAY_OF_MONTH | back to summary |
|---|---|
| pack-priv static final int PATTERN_DAY_OF_MONTH | |
| PATTERN_DAY_OF_WEEK | back to summary |
|---|---|
| pack-priv static final int PATTERN_DAY_OF_WEEK | |
| PATTERN_DAY_OF_WEEK_IN_MONTH | back to summary |
|---|---|
| pack-priv static final int PATTERN_DAY_OF_WEEK_IN_MONTH | |
| PATTERN_DAY_OF_YEAR | back to summary |
|---|---|
| pack-priv static final int PATTERN_DAY_OF_YEAR | |
| PATTERN_ERA | back to summary |
|---|---|
| pack-priv static final int PATTERN_ERA | |
| PATTERN_HOUR0 | back to summary |
|---|---|
| pack-priv static final int PATTERN_HOUR0 | |
| PATTERN_HOUR1 | back to summary |
|---|---|
| pack-priv static final int PATTERN_HOUR1 | |
| PATTERN_HOUR_OF_DAY0 | back to summary |
|---|---|
| pack-priv static final int PATTERN_HOUR_OF_DAY0 | |
| PATTERN_HOUR_OF_DAY1 | back to summary |
|---|---|
| pack-priv static final int PATTERN_HOUR_OF_DAY1 | |
| PATTERN_ISO_DAY_OF_WEEK | back to summary |
|---|---|
| pack-priv static final int PATTERN_ISO_DAY_OF_WEEK | |
| PATTERN_ISO_ZONE | back to summary |
|---|---|
| pack-priv static final int PATTERN_ISO_ZONE | |
| PATTERN_MILLISECOND | back to summary |
|---|---|
| pack-priv static final int PATTERN_MILLISECOND | |
| PATTERN_MINUTE | back to summary |
|---|---|
| pack-priv static final int PATTERN_MINUTE | |
| PATTERN_MONTH | back to summary |
|---|---|
| pack-priv static final int PATTERN_MONTH | |
| PATTERN_MONTH_STANDALONE | back to summary |
|---|---|
| pack-priv static final int PATTERN_MONTH_STANDALONE | |
| PATTERN_SECOND | back to summary |
|---|---|
| pack-priv static final int PATTERN_SECOND | |
| PATTERN_WEEK_OF_MONTH | back to summary |
|---|---|
| pack-priv static final int PATTERN_WEEK_OF_MONTH | |
| PATTERN_WEEK_OF_YEAR | back to summary |
|---|---|
| pack-priv static final int PATTERN_WEEK_OF_YEAR | |
| PATTERN_WEEK_YEAR | back to summary |
|---|---|
| pack-priv static final int PATTERN_WEEK_YEAR | |
| PATTERN_YEAR | back to summary |
|---|---|
| pack-priv static final int PATTERN_YEAR | |
| PATTERN_ZONE_NAME | back to summary |
|---|---|
| pack-priv static final int PATTERN_ZONE_NAME | |
| PATTERN_ZONE_VALUE | back to summary |
|---|---|
| pack-priv static final int PATTERN_ZONE_VALUE | |
| patternChars | back to summary |
|---|---|
| pack-priv static final String patternChars Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All locales use the same these unlocalized pattern characters. | |
| serialVersionUID | back to summary |
|---|---|
| pack-priv static final long serialVersionUID
| |
| shortMonths | back to summary |
|---|---|
| pack-priv String[] shortMonths Short month strings. For example: "Jan", "Feb", etc. An array of
13 strings (some calendars have 13 months), indexed by
| |
| shortWeekdays | back to summary |
|---|---|
| pack-priv String[] shortWeekdays Short weekday strings. For example: "Sun", "Mon", etc. An array
of 8 strings, indexed by | |
| weekdays | back to summary |
|---|---|
| pack-priv String[] weekdays Weekday strings. For example: "Sunday", "Monday", etc. An array
of 8 strings, indexed by | |
| zoneStrings | back to summary |
|---|---|
| pack-priv String[][] zoneStrings Localized 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 class that are not
custom IDs.
All other entries are localized names.
| |
| DateFormatSymbols | back to summary |
|---|---|
| public DateFormatSymbols() Construct a DateFormatSymbols object by loading format data from
resources for the default This is equivalent to calling
| |
| DateFormatSymbols | back to summary |
|---|---|
| public DateFormatSymbols(Locale locale) Construct a DateFormatSymbols object by loading format data from
resources for the given locale. This constructor can only
construct instances for the locales supported by the Java
runtime environment, not for those supported by installed
| |
| DateFormatSymbols | back to summary |
|---|---|
| private DateFormatSymbols(boolean flag) Constructs an uninitialized DateFormatSymbols. | |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Overrides Cloneable | |
| copyMembers | back to summary |
|---|---|
| private void copyMembers(DateFormatSymbols src, DateFormatSymbols dst) Clones all the data members from the source DateFormatSymbols to the target DateFormatSymbols.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares the specified object with this Implementation Specification This method performs an equality check with a notion of class
identity based on
| |
| getAmPmStrings | back to summary |
|---|---|
| public String[] getAmPmStrings() Gets ampm strings. For example: "AM" and "PM".
| |
| getAvailableLocales | back to summary |
|---|---|
| public static Locale[] getAvailableLocales() Returns an array of all locales for which the
| |
| getEras | back to summary |
|---|---|
| public String[] getEras() Gets era strings. For example: "AD" and "BC".
| |
| getInstance | back to summary |
|---|---|
| public static final DateFormatSymbols getInstance() Gets the This is equivalent to calling
| |
| getInstance | back to summary |
|---|---|
| public static final DateFormatSymbols getInstance(Locale locale) Gets the
| |
| getLocalPatternChars | back to summary |
|---|---|
| public String getLocalPatternChars() Gets localized date-time pattern characters. For example: 'u', 't', etc.
| |
| getMonths | back to summary |
|---|---|
| public String[] getMonths() Gets month strings. For example: "January", "February", etc.
An array with either 12 or 13 elements will be returned depending
on whether or not If the language requires different forms for formatting and
stand-alone usages, this method returns month names in the
formatting form. For example, the preferred month name for
January in the Czech language is ledna in the
formatting form, while it is leden in the stand-alone
form. This method returns Implementation Specification This method returns 13 elements since
| |
| getProviderInstance | back to summary |
|---|---|
| private static DateFormatSymbols getProviderInstance(Locale locale) | |
| getShortMonths | back to summary |
|---|---|
| public String[] getShortMonths() Gets short month strings. For example: "Jan", "Feb", etc.
An array with either 12 or 13 elements will be returned depending
on whether or not If the language requires different forms for formatting and
stand-alone usages, this method returns short month names in
the formatting form. For example, the preferred abbreviation
for January in the Catalan language is de gen. in the
formatting form, while it is gen. in the stand-alone
form. This method returns Implementation Specification This method returns 13 elements since
| |
| getShortWeekdays | back to summary |
|---|---|
| public String[] getShortWeekdays() Gets short weekday strings. For example: "Sun", "Mon", etc.
| |
| getWeekdays | back to summary |
|---|---|
| public String[] getWeekdays() Gets weekday strings. For example: "Sunday", "Monday", etc.
| |
| getZoneIndex | back to summary |
|---|---|
| pack-priv final int getZoneIndex(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!!!
| |
| getZoneStrings | back to summary |
|---|---|
| public String[][] getZoneStrings() Gets time zone strings. Use of this method is discouraged; use
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 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
| |
| getZoneStringsImpl | back to summary |
|---|---|
| private String[][] getZoneStringsImpl(boolean needsCopy) | |
| getZoneStringsWrapper | back to summary |
|---|---|
| pack-priv final 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. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code for this Implementation Specification Non-transient instance fields of this class are used to calculate
a hash code value which adheres to the contract defined in
| |
| initializeData | back to summary |
|---|---|
| private void initializeData(Locale locale) Initializes this DateFormatSymbols with the locale data. This method uses a cached DateFormatSymbols instance for the given locale if available. If there's no cached one, this method creates an uninitialized instance and populates its fields from the resource bundle for the locale, and caches the instance. Note zoneStrings isn't initialized in this method. | |
| isSubclassObject | back to summary |
|---|---|
| private boolean isSubclassObject() | |
| setAmPmStrings | back to summary |
|---|---|
| public void setAmPmStrings(String[] newAmpms) Sets ampm strings. For example: "AM" and "PM".
| |
| setEras | back to summary |
|---|---|
| public void setEras(String[] newEras) Sets era strings. For example: "AD" and "BC".
| |
| setLocalPatternChars | back to summary |
|---|---|
| public void setLocalPatternChars(String newLocalPatternChars) Sets localized date-time pattern characters. For example: 'u', 't', etc.
| |
| setMonths | back to summary |
|---|---|
| public void setMonths(String[] newMonths) Sets month strings. For example: "January", "February", etc.
| |
| setShortMonths | back to summary |
|---|---|
| public void setShortMonths(String[] newShortMonths) Sets short month strings. For example: "Jan", "Feb", etc.
| |
| setShortWeekdays | back to summary |
|---|---|
| public void setShortWeekdays(String[] newShortWeekdays) Sets short weekday strings. For example: "Sun", "Mon", etc.
| |
| setWeekdays | back to summary |
|---|---|
| public void setWeekdays(String[] newWeekdays) Sets weekday strings. For example: "Sunday", "Monday", etc.
| |
| setZoneStrings | back to summary |
|---|---|
| public void setZoneStrings(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 class that are not
custom IDs.
All other entries are localized names.
| |
| toOneBasedArray | back to summary |
|---|---|
| private static String[] toOneBasedArray(String[] src) | |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream stream) throws IOException Write out the default serializable data, after ensuring the
| |