Home » openjdk-7 » java » text » [javadoc | source]
java.text
public class: DateFormatSymbols [javadoc | source]
java.lang.Object
   java.text.DateFormatSymbols

All Implemented Interfaces:
    Cloneable, Serializable

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, DateFormatSymbols.getInstance(aLocale)).

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.

Field Summary
 String[] eras    Era strings. For example: "AD" and "BC". An array of 2 strings, indexed by Calendar.BC and Calendar.AD.
    serial:
 
 String[] months    Month strings. For example: "January", "February", etc. An array of 13 strings (some calendars have 13 months), indexed by Calendar.JANUARY, Calendar.FEBRUARY, etc.
    serial:
 
 String[] shortMonths    Short month strings. For example: "Jan", "Feb", etc. An array of 13 strings (some calendars have 13 months), indexed by Calendar.JANUARY, Calendar.FEBRUARY, etc.
    serial:
 
 String[] weekdays    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.
    serial:
 
 String[] shortWeekdays    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.
    serial:
 
 String[] ampms    AM and PM strings. For example: "AM" and "PM". An array of 2 strings, indexed by Calendar.AM and Calendar.PM.
    serial:
 
 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. 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 TimeZone class that are not custom IDs. All other entries are localized names. 
transient  boolean isZoneStringsSet    Indicates that zoneStrings is set externally with setZoneStrings() method. 
static final  String patternChars    Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All locales use the same these unlocalized pattern characters. 
static final  int PATTERN_ERA     
static final  int PATTERN_YEAR     
static final  int PATTERN_MONTH     
static final  int PATTERN_DAY_OF_MONTH     
static final  int PATTERN_HOUR_OF_DAY1     
static final  int PATTERN_HOUR_OF_DAY0     
static final  int PATTERN_MINUTE     
static final  int PATTERN_SECOND     
static final  int PATTERN_MILLISECOND     
static final  int PATTERN_DAY_OF_WEEK     
static final  int PATTERN_DAY_OF_YEAR     
static final  int PATTERN_DAY_OF_WEEK_IN_MONTH     
static final  int PATTERN_WEEK_OF_YEAR     
static final  int PATTERN_WEEK_OF_MONTH     
static final  int PATTERN_AM_PM     
static final  int PATTERN_HOUR1     
static final  int PATTERN_HOUR0     
static final  int PATTERN_ZONE_NAME     
static final  int PATTERN_ZONE_VALUE     
static final  int PATTERN_WEEK_YEAR     
static final  int PATTERN_ISO_DAY_OF_WEEK     
static final  int PATTERN_ISO_ZONE     
 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 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.
    serial:
 
 Locale locale    The locale which is used for initializing this DateFormatSymbols object.
    since: 1.6 -
    serial:
 
static final  long serialVersionUID     
static final  int millisPerHour    Useful constant for defining time zone offsets. 
Constructor:
 public DateFormatSymbols() 
    Throws:
    java.util.MissingResourceException - if the resources for the default locale cannot be found or cannot be loaded.
    Also see:
    getInstance()
    exception: java.util.MissingResourceException - if the resources for the default locale cannot be found or cannot be loaded.
 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 DateFormatSymbolsProvider implementations. For full locale coverage, use the getInstance method.
    Throws:
    java.util.MissingResourceException - if the resources for the specified locale cannot be found or cannot be loaded.
    Also see:
    getInstance(Locale)
    exception: java.util.MissingResourceException - if the resources for the specified locale cannot be found or cannot be loaded.
Method from java.text.DateFormatSymbols Summary:
clone,   equals,   getAmPmStrings,   getAvailableLocales,   getEras,   getInstance,   getInstance,   getInstanceRef,   getLocalPatternChars,   getMonths,   getShortMonths,   getShortWeekdays,   getWeekdays,   getZoneIndex,   getZoneStrings,   getZoneStringsWrapper,   hashCode,   setAmPmStrings,   setEras,   setLocalPatternChars,   setMonths,   setShortMonths,   setShortWeekdays,   setWeekdays,   setZoneStrings
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.text.DateFormatSymbols Detail:
 public Object clone() 
    Overrides Cloneable
 public boolean equals(Object obj) 
    Override equals
 public String[] getAmPmStrings() 
    Gets ampm strings. For example: "AM" and "PM".
 public static 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 DateFormatSymbolsProvider implementations. It must contain at least a Locale instance equal to Locale.US .
 public String[] getEras() 
    Gets era strings. For example: "AD" and "BC".
 public static final 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 DateFormatSymbolsProvider implementations.
 public static final DateFormatSymbols getInstance(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 DateFormatSymbolsProvider implementations.
 static final DateFormatSymbols getInstanceRef(Locale locale) 
    Returns a DateFormatSymbols provided by a provider or found in the cache. Note that this method returns a cached instance, not its clone. Therefore, the instance should never be given to an application.
 public String getLocalPatternChars() 
    Gets localized date-time pattern characters. For example: 'u', 't', etc.
 public String[] getMonths() 
    Gets month strings. For example: "January", "February", etc.
 public String[] getShortMonths() 
    Gets short month strings. For example: "Jan", "Feb", etc.
 public String[] getShortWeekdays() 
    Gets short weekday strings. For example: "Sun", "Mon", etc.
 public String[] getWeekdays() 
    Gets weekday strings. For example: "Sunday", "Monday", etc.
 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!!!
 public String[][] getZoneStrings() 
    Gets time zone strings. Use of this method is discouraged; use 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 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 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 TimeZoneNameProvider implementations.

 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 hashCode() 
    Override hashCode. Generates a hash code for the DateFormatSymbols object.
 public  void setAmPmStrings(String[] newAmpms) 
    Sets ampm strings. For example: "AM" and "PM".
 public  void setEras(String[] newEras) 
    Sets era strings. For example: "AD" and "BC".
 public  void setLocalPatternChars(String newLocalPatternChars) 
    Sets localized date-time pattern characters. For example: 'u', 't', etc.
 public  void setMonths(String[] newMonths) 
    Sets month strings. For example: "January", "February", etc.
 public  void setShortMonths(String[] newShortMonths) 
    Sets short month strings. For example: "Jan", "Feb", etc.
 public  void setShortWeekdays(String[] newShortWeekdays) 
    Sets short weekday strings. For example: "Sun", "Mon", etc.
 public  void setWeekdays(String[] newWeekdays) 
    Sets weekday strings. For example: "Sunday", "Monday", etc.
 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. 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 TimeZone class that are not custom IDs. All other entries are localized names.