Top Description Inners Fields Constructors Methods
com.ibm.icu.text

public Class DateFormatSymbols

extends Object
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Known Direct Subclasses
com.ibm.icu.text.ChineseDateFormatSymbols
Imports
java.io.IOException, .ObjectInputStream, .Serializable, java.util.ArrayList, .HashMap, .HashSet, .List, .Locale, .Map, .MissingResourceException, .ResourceBundle, .Set, .TreeMap, com.ibm.icu.impl.CacheBase, .CalendarUtil, .ICUData, .ICUResourceBundle, .SoftCache, .UResource, .Utility, com.ibm.icu.text.TimeZoneNames.NameType, com.ibm.icu.util.Calendar, .ICUCloneNotSupportedException, .ICUException, .TimeZone, .ULocale, .ULocale.Category, .UResourceBundle, .UResourceBundleIterator

ICU Enhancement

This class is ICU's replacement for java.text.DateFormatSymbols.

ICU

Methods, fields, and other functionality specific to ICU are labeled 'ICU'.

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. DateFormat and SimpleDateFormat both use 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, new DateFormatSymbols(aLocale)).

DateFormatSymbols objects are clonable. 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.

Author
Chen-Lieh Huang
ICU Status
Stable since ICU 2.0.
See Also
DateFormat, SimpleDateFormat, com.ibm.icu.util.SimpleTimeZone

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DateFormatSymbols.CalendarDataSink

Sink to enumerate the calendar data

pack-priv static enum

Field Summary

Modifier and TypeField and Description
public static final int
pack-priv String[]
abbreviatedDayPeriods

Localized names for abbreviated (== short) day periods.

private ULocale
actualLocale

The locale containing data used to construct this object, or null.

pack-priv static final String
pack-priv String[]
ampms

AM and PM strings.

pack-priv String[]
ampmsNarrow

narrow AM and PM strings.

private static final String[][]
pack-priv Map<DateFormatSymbols.CapitalizationContextUsage, boolean[]>
capitalization

Capitalization transforms.

private static final Map<String, DateFormatSymbols.CapitalizationContextUsage>
contextUsageTypeMap

Map from resource key to CapitalizationContextUsage value

private static final String[]
DAY_PERIOD_KEYS

Keys for dayPeriods

pack-priv static final String
private static CacheBase<String, DateFormatSymbols, ULocale>
public 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
public static final int
pack-priv String[]
eraNames

Era name strings.

pack-priv String[]
eras

Era strings.

public static final int
FORMAT

ICU

private static final String[]
LEAP_MONTH_PATTERNS_PATHS

Resource bundle paths for each leap month pattern

pack-priv String[]
leapMonthPatterns

All leap month patterns, for example "{0}bis".

pack-priv String
localPatternChars

Localized date-time pattern characters.

pack-priv static final int
millisPerHour

Useful constant for defining timezone offsets.

pack-priv String[]
months

Month strings.

public static final int
NARROW

ICU

pack-priv String[]
narrowDayPeriods

Localized names for narrow day periods.

pack-priv String[]
narrowEras

Narrow era names.

pack-priv String[]
narrowMonths

Narrow month strings.

pack-priv String[]
narrowQuarters

Narrow quarter names.

pack-priv String[]
narrowWeekdays

CLDR-style format narrow weekday strings, for example: "S", "M", etc. An array of 8 strings, indexed by Calendar.SUNDAY, Calendar.MONDAY, etc. The element narrowWeekdays[0] is ignored.

public static final int
pack-priv static final String
patternChars

Unlocalized date-time pattern characters.

pack-priv String[]
quarters

Full quarter names.

private ULocale
private static final long
public static final int
SHORT

ICU

pack-priv String[]
shorterWeekdays

CLDR-style format short weekday strings, for example: "Su", "Mo", etc. An array of 8 strings, indexed by Calendar.SUNDAY, Calendar.MONDAY, etc. The element shorterWeekdays[0] is ignored.

pack-priv String[]
shortMonths

Short month strings.

pack-priv String[]
shortQuarters

Abbreviated quarter names.

pack-priv String[]
shortWeekdays

CLDR-style format abbreviated (not short) 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.

pack-priv String[]
shortYearNames

Cyclic year names, for example: "jia-zi", "yi-chou", ...

pack-priv String[]
shortZodiacNames

Cyclic zodiac names, for example: "Rat", "Ox", "Tiger", etc. An array of (normally) 12 strings.

public static final int
pack-priv String[]
standaloneAbbreviatedDayPeriods

Localized names for standalone abbreviated (== short) day periods.

pack-priv String[]
standaloneMonths

Standalone month strings.

pack-priv String[]
standaloneNarrowDayPeriods

Localized names for standalone narrow day periods.

pack-priv String[]
standaloneNarrowMonths

Standalone narrow month strings.

pack-priv String[]
standaloneNarrowQuarters

Standalone narrow quarter names.

pack-priv String[]
standaloneNarrowWeekdays

Standalone narrow weekday strings.

pack-priv String[]
standaloneQuarters

Standalone full quarter names.

pack-priv String[]
standaloneShorterWeekdays

CLDR-style standalone short weekday strings, for example: "Sun", "Mon", etc. An array of 8 strings, indexed by Calendar.SUNDAY, Calendar.MONDAY, etc. The element standaloneShorterWeekdays[0] is ignored.

pack-priv String[]
standaloneShortMonths

Standalone short month strings.

pack-priv String[]
standaloneShortQuarters

Standalone abbreviated quarter names.

pack-priv String[]
standaloneShortWeekdays

CLDR-style standalone abbreviated (not short) weekday strings, for example: "Sun", "Mon", etc. An array of 8 strings, indexed by Calendar.SUNDAY, Calendar.MONDAY, etc. The element standaloneShortWeekdays[0] is ignored.

pack-priv String[]
standaloneWeekdays

Standalone wide weekday strings.

pack-priv String[]
standaloneWideDayPeriods

Localized names for standalone wide day periods.

private String
timeSeparator

Time separator string.

private ULocale
validLocale

The most specific locale containing any resource data, or null.

pack-priv String[]
weekdays

Format wide weekday strings, for example: "Sunday", "Monday", etc. An array of 8 strings, indexed by Calendar.SUNDAY, Calendar.MONDAY, etc. The element weekdays[0] is ignored.

public static final int
WIDE

ICU

pack-priv String[]
wideDayPeriods

Localized names for wide day periods.

private String[][]
zoneStrings

Localized names of time zones in this locale.

Constructor Summary

AccessConstructor and Description
public
DateFormatSymbols()

Constructs a DateFormatSymbols object by loading format data from resources for the default FORMAT locale.

public
DateFormatSymbols(Locale locale)

Constructs a DateFormatSymbols object by loading format data from resources for the given locale.

public
private
DateFormatSymbols(ULocale desiredLocale, ICUResourceBundle b, String calendarType)

Private, for cache.getInstance().

public
DateFormatSymbols(Calendar
The calendar system whose date format symbols are desired.
cal
,
Locale
The locale whose symbols are desired.
locale
)

Returns the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

public
DateFormatSymbols(Calendar
The calendar system whose date format symbols are desired.
cal
,
ULocale
The ulocale whose symbols are desired.
locale
)

Returns the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

public
DateFormatSymbols(Class<? extends Calendar> calendarClass, Locale locale)

Variant of DateFormatSymbols(Calendar, Locale) that takes the Calendar class instead of a Calendar instance.

public
DateFormatSymbols(Class<? extends Calendar> calendarClass, ULocale locale)

Variant of DateFormatSymbols(Calendar, ULocale) that takes the Calendar class instead of a Calendar instance.

public
DateFormatSymbols(ResourceBundle bundle, Locale locale)

Fetches a custom calendar's DateFormatSymbols out of the given resource bundle.

public
DateFormatSymbols(ResourceBundle bundle, ULocale locale)

Fetches a custom calendar's DateFormatSymbols out of the given resource bundle.

Method Summary

Modifier and TypeMethod and Description
private static final boolean
arrayOfArrayEquals(Object[][] aa1, Object[][] aa2)

public Object
clone()

Overrides java.lang.Object.clone.

Overrides clone.
private final String[]
duplicate(String[] srcArray)

private final String[][]
duplicate(String[][] srcArray)

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Overrides equals.
public String[]

Returns:

the weekday strings.
getAmPmStrings
()

Returns am/pm strings.

public static Locale[]

Returns:

An array of Locales for which localized DateFormatSymbols instances are available.
getAvailableLocales
()

Returns an array of all locales for which the getInstance methods of this class can return localized instances.

public static ULocale[]

Returns:

An array of ULocales for which localized DateFormatSymbols instances are available.
getAvailableULocales
()

ICU

public static ResourceBundle
getDateFormatBundle(Class<? extends Calendar> calendarClass, Locale locale)

Deprecated ICU 4.0
Finds the ResourceBundle containing the date format information for a specified calendar subclass in a given locale.
public static ResourceBundle
getDateFormatBundle(Class<? extends Calendar> calendarClass, ULocale locale)

Deprecated ICU 4.0
Finds the ResourceBundle containing the date format information for a specified calendar subclass in a given locale.
public static ResourceBundle
getDateFormatBundle(Calendar cal, Locale locale)

Deprecated ICU 4.0
Variant of getDateFormatBundle(java.lang.Class, java.util.Locale) that takes a Calendar instance instead of a Calendar class.
public static ResourceBundle
getDateFormatBundle(Calendar cal, ULocale locale)

Deprecated ICU 4.0
Variant of getDateFormatBundle(java.lang.Class, java.util.Locale) that takes a Calendar instance instead of a Calendar class.
public String[]

Returns:

the era strings.
getEraNames
()

ICU

public String[]

Returns:

the era strings.
getEras
()

Returns abbreviated era strings.

public static DateFormatSymbols

Returns:

A DateFormatSymbols instance.
getInstance
()

Returns a DateFormatSymbols instance for the default locale.

public static DateFormatSymbols

Returns:

A DateFormatSymbols instance.
getInstance
(Locale
the locale.
locale
)

Returns a DateFormatSymbols instance for the given locale.

public static DateFormatSymbols

Returns:

A DateFormatSymbols instance.
getInstance
(ULocale
the locale.
locale
)

ICU

public String

Returns:

The leapMonthPattern, or null if not available for this calendar.
getLeapMonthPattern
(int
The usage context: FORMAT, STANDALONE, NUMERIC.
context
,
int
The requested pattern width: WIDE, ABBREVIATED, SHORT, NARROW.
width
)

Deprecated This API is ICU internal only.
Returns the appropriate leapMonthPattern if the calendar has them, for example: "{0}bis"
public final ULocale

Returns:

the information specified by type, or null if this object was not constructed from locale data.
getLocale
(ULocale.Type type)

Returns the locale that was used to create this object, or null.

public String

Returns:

the localized date-time pattern characters.
getLocalPatternChars
()

Returns localized date-time pattern characters.

public String[]

Returns:

the month strings.
getMonths
()

Returns month strings.

public String[]

Returns:

the month strings.
getMonths
(int
The month context, FORMAT or STANDALONE.
context
,
int
The width or the returned month string, either WIDE, ABBREVIATED, or NARROW.
width
)

Returns month strings.

public String[]

Returns:

the narrow era strings.
getNarrowEras
()

ICU

public String[]

Returns:

the quarter strings.
getQuarters
(int
The quarter context, FORMAT or STANDALONE.
context
,
int
The width or the returned quarter string, WIDE, NARROW, or ABBREVIATED.
width
)

ICU

public String[]

Returns:

the short month strings.
getShortMonths
()

Returns short month strings.

public String[]

Returns:

the abbreviated weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.
getShortWeekdays
()

Returns abbreviated weekday strings; for example: "Sun", "Mon", etc. (Note: the method name is misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)

public String

Returns:

the time separator string.
getTimeSeparatorString
()

Deprecated This API is ICU internal only.
Returns the time separator string.
public String[]

Returns:

the weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.
getWeekdays
()

Returns wide weekday strings.

public String[]

Returns:

the weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.
getWeekdays
(int
Formatting context, either FORMAT or STANDALONE.
context
,
int
Width of strings to be returned, either WIDE, ABBREVIATED, SHORT, or NARROW
width
)

Returns weekday strings.

public String[]

Returns:

The year name strings, or null if they are not available for this calendar.
getYearNames
(int
The usage context: FORMAT, STANDALONE.
context
,
int
The requested name width: WIDE, ABBREVIATED, SHORT, NARROW.
width
)

Returns cyclic year name strings if the calendar has them, for example: "jia-zi", "yi-chou", etc.

public String[]

Returns:

The zodiac name strings, or null if they are not available for this calendar.
getZodiacNames
(int
The usage context: FORMAT, STANDALONE.
context
,
int
The requested name width: WIDE, ABBREVIATED, SHORT, NARROW.
width
)

Returns calendar zodiac name strings if the calendar has them, for example: "Rat", "Ox", "Tiger", etc.

public String[][]

Returns:

the time zone strings.
getZoneStrings
()

Returns time zone strings.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Override hashCode.
protected void
initializeData(ULocale
The locale whose symbols are desired.
desiredLocale
,
String
The calendar type whose date format symbols are desired.
type
)

Initializes format symbols for the locale and calendar type

pack-priv void
initializeData(DateFormatSymbols dfs)

Initializes format symbols using another instance.

protected void
initializeData(ULocale
The locale whose symbols are desired.
desiredLocale
,
ICUResourceBundle
Resource bundle provided externally
b
,
String
The calendar type being used
calendarType
)

Deprecated This API is ICU internal only.
Initializes format symbols for the locale and calendar type
private String[]
loadDayPeriodStrings(Map<String, String>
Contains the dayPeriod resource to load
resourceMap
,
String[]
If non-null, any values in the result that would otherwise be null are copied from this array
copyFrom
)

Loads localized names for day periods in the requested format.

private void
readObject(ObjectInputStream stream)

3.8 or older version did not have localized GMT format patterns.

public void
setAmPmStrings(String[]
the new ampm strings.
newAmpms
)

Sets am/pm strings.

public void
setEraNames(String[]
the new era strings.
newEraNames
)

ICU

public void
setEras(String[]
the new era strings.
newEras
)

Sets abbreviated era strings.

public void
setLeapMonthPattern(String
The new leapMonthPattern.
leapMonthPattern
,
int
The usage context: FORMAT, STANDALONE, NUMERIC.
context
,
int
The name width: WIDE, ABBREVIATED, NARROW.
width
)

Deprecated This API is ICU internal only.
Sets a leapMonthPattern, for example: "{0}bis"
pack-priv final void
setLocale(ULocale
the most specific locale containing any resource data, or null
valid
,
ULocale
the locale containing data used to construct this object, or null
actual
)

Sets information about the locales that were used to create this object.

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.
newMonths
)

Sets month strings.

public void
setMonths(String[]
the new month strings.
newMonths
,
int
The formatting context, FORMAT or STANDALONE.
context
,
int
The width of the month string, either WIDE, ABBREVIATED, or NARROW.
width
)

Sets month strings.

public void
setNarrowEras(String[]
the new narrow era strings.
newNarrowEras
)

ICU

public void
setQuarters(String[]
the new quarter strings.
newQuarters
,
int
The formatting context, FORMAT or STANDALONE.
context
,
int
The width of the quarter string, WIDE, NARROW, or ABBREVIATED.
width
)

ICU

public void
setShortMonths(String[]
the new short month strings.
newShortMonths
)

Sets short month strings.

public void
setShortWeekdays(String[]
the new abbreviated weekday strings. The array should be indexed by Calendar.SUNDAY, Calendar.MONDAY, etc.
newAbbrevWeekdays
)

Sets abbreviated weekday strings; for example: "Sun", "Mon", etc. (Note: the method name is misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)

public void
setTimeSeparatorString(String
the new time separator string.
newTimeSeparator
)

Deprecated This API is ICU internal only.
Sets the time separator string.
public void
setWeekdays(String[]
The new weekday strings.
newWeekdays
,
int
The formatting context, FORMAT or STANDALONE.
context
,
int
The width of the strings, either WIDE, ABBREVIATED, SHORT, or NARROW.
width
)

Sets weekday strings.

public void
setWeekdays(String[]
the new weekday strings. The array should be indexed by Calendar.SUNDAY, Calendar.MONDAY, etc.
newWeekdays
)

Sets wide weekday strings.

public void
setYearNames(String[]
The new cyclic year name strings.
yearNames
,
int
The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
context
,
int
The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
width
)

Sets cyclic year name strings, for example: "jia-zi", "yi-chou", etc.

public void
setZodiacNames(String[]
The new zodiac name strings.
zodiacNames
,
int
The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
context
,
int
The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
width
)

Sets calendar zodiac name strings, for example: "Rat", "Ox", "Tiger", etc.

public void
setZoneStrings(String[][]
the new time zone strings.
newZoneStrings
)

Sets time zone strings.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAlltoStringwaitwaitwait