com.ibm.text
Class DateFormatSymbols

java.lang.Object
  |
  +--com.ibm.text.DateFormatSymbols
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
ChineseDateFormatSymbols

public class DateFormatSymbols
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

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.

Version:
1.31 09/21/99
Author:
Chen-Lieh Huang
See Also:
DateFormat, SimpleDateFormat, SimpleTimeZone, Serialized Form

Constructor Summary
DateFormatSymbols()
          Construct a DateFormatSymbols object by loading format data from resources for the default locale.
DateFormatSymbols(Calendar cal, java.util.Locale locale)
          Get the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.
DateFormatSymbols(java.lang.Class calendarClass, java.util.Locale locale)
           
DateFormatSymbols(java.util.Locale locale)
          Construct a DateFormatSymbols object by loading format data from resources for the given locale.
DateFormatSymbols(java.util.ResourceBundle bundle, java.util.Locale locale)
          Fetch a custom calendar's DateFormatSymbols out of the given resource bundle.
 
Method Summary
 java.lang.Object clone()
          Overrides Cloneable
protected  void constructCalendarSpecific(java.util.ResourceBundle bundle)
          Given a resource bundle specific to the given Calendar class, initialize this object.
 boolean equals(java.lang.Object obj)
          Override equals
 java.lang.String[] getAmPmStrings()
          Gets ampm strings.
static java.util.ResourceBundle getDateFormatBundle(Calendar cal, java.util.Locale locale)
           
static java.util.ResourceBundle getDateFormatBundle(java.lang.Class calendarClass, java.util.Locale locale)
          Find the ResourceBundle containing the date format information for a specified calendar subclass in a given locale.
 java.lang.String[] getEras()
          Gets era strings.
 java.lang.String getLocalPatternChars()
          Gets localized date-time pattern characters.
 java.lang.String[] getMonths()
          Gets month strings.
 java.lang.String[] getShortMonths()
          Gets short month strings.
 java.lang.String[] getShortWeekdays()
          Gets short weekday strings.
 java.lang.String[] getWeekdays()
          Gets weekday strings.
 java.lang.String[][] getZoneStrings()
          Gets timezone strings.
 int hashCode()
          Override hashCode.
 void setAmPmStrings(java.lang.String[] newAmpms)
          Sets ampm strings.
 void setEras(java.lang.String[] newEras)
          Sets era strings.
 void setLocalPatternChars(java.lang.String newLocalPatternChars)
          Sets localized date-time pattern characters.
 void setMonths(java.lang.String[] newMonths)
          Sets month strings.
 void setShortMonths(java.lang.String[] newShortMonths)
          Sets short month strings.
 void setShortWeekdays(java.lang.String[] newShortWeekdays)
          Sets short weekday strings.
 void setWeekdays(java.lang.String[] newWeekdays)
          Sets weekday strings.
 void setZoneStrings(java.lang.String[][] newZoneStrings)
          Sets timezone strings.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatSymbols

public DateFormatSymbols()
Construct a DateFormatSymbols object by loading format data from resources for the default locale.
Throws:
java.util.MissingResourceException - if the resources for the default locale cannot be found or cannot be loaded.

DateFormatSymbols

public DateFormatSymbols(java.util.Locale locale)
Construct a DateFormatSymbols object by loading format data from resources for the given locale.
Throws:
java.util.MissingResourceException - if the resources for the specified locale cannot be found or cannot be loaded.

DateFormatSymbols

public DateFormatSymbols(Calendar cal,
                         java.util.Locale locale)
Get the DateFormatSymbols object that should be used to format a calendar system's dates in the given locale.

Subclassing:
When creating a new Calendar subclass, you must create the ResourceBundle containing its DateFormatSymbols in a specific place. The resource bundle name is based on the calendar's fully-specified class name, with ".resources" inserted at the end of the package name (just before the class name) and "Symbols" appended to the end. For example, the bundle corresponding to "com.ibm.util.HebrewCalendar" is "com.ibm.util.resources.HebrewCalendarSymbols".

Within the ResourceBundle, this method searches for five keys:

Parameters:
cal - The calendar system whose date format symbols are desired.
locale - The locale whose symbols are desired.
See Also:
DateFormatSymbols(java.util.Locale)

DateFormatSymbols

public DateFormatSymbols(java.lang.Class calendarClass,
                         java.util.Locale locale)

DateFormatSymbols

public DateFormatSymbols(java.util.ResourceBundle bundle,
                         java.util.Locale locale)
Fetch a custom calendar's DateFormatSymbols out of the given resource bundle. Symbols that are not overridden are inherited from the default DateFormatSymbols for the locale.
See Also:
DateFormatSymbols()
Method Detail

getEras

public java.lang.String[] getEras()
Gets era strings. For example: "AD" and "BC".
Returns:
the era strings.

setEras

public void setEras(java.lang.String[] newEras)
Sets era strings. For example: "AD" and "BC".
Parameters:
newEras - the new era strings.

getMonths

public java.lang.String[] getMonths()
Gets month strings. For example: "January", "February", etc.
Returns:
the month strings.

setMonths

public void setMonths(java.lang.String[] newMonths)
Sets month strings. For example: "January", "February", etc.
Parameters:
newMonths - the new month strings.

getShortMonths

public java.lang.String[] getShortMonths()
Gets short month strings. For example: "Jan", "Feb", etc.
Returns:
the short month strings.

setShortMonths

public void setShortMonths(java.lang.String[] newShortMonths)
Sets short month strings. For example: "Jan", "Feb", etc.
Parameters:
newShortMonths - the new short month strings.

getWeekdays

public java.lang.String[] getWeekdays()
Gets weekday strings. For example: "Sunday", "Monday", etc.
Returns:
the weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.

setWeekdays

public void setWeekdays(java.lang.String[] newWeekdays)
Sets weekday strings. For example: "Sunday", "Monday", etc.
Parameters:
newWeekdays - the new weekday strings. The array should be indexed by Calendar.SUNDAY, Calendar.MONDAY, etc.

getShortWeekdays

public java.lang.String[] getShortWeekdays()
Gets short weekday strings. For example: "Sun", "Mon", etc.
Returns:
the short weekday strings. Use Calendar.SUNDAY, Calendar.MONDAY, etc. to index the result array.

setShortWeekdays

public void setShortWeekdays(java.lang.String[] newShortWeekdays)
Sets short weekday strings. For example: "Sun", "Mon", etc.
Parameters:
newShortWeekdays - the new short weekday strings. The array should be indexed by Calendar.SUNDAY, Calendar.MONDAY, etc.

getAmPmStrings

public java.lang.String[] getAmPmStrings()
Gets ampm strings. For example: "AM" and "PM".
Returns:
the weekday strings.

setAmPmStrings

public void setAmPmStrings(java.lang.String[] newAmpms)
Sets ampm strings. For example: "AM" and "PM".
Parameters:
newAmpms - the new ampm strings.

getZoneStrings

public java.lang.String[][] getZoneStrings()
Gets timezone strings.
Returns:
the timezone strings.

setZoneStrings

public void setZoneStrings(java.lang.String[][] newZoneStrings)
Sets timezone strings.
Parameters:
newZoneStrings - the new timezone strings.

getLocalPatternChars

public java.lang.String getLocalPatternChars()
Gets localized date-time pattern characters. For example: 'u', 't', etc.
Returns:
the localized date-time pattern characters.

setLocalPatternChars

public void setLocalPatternChars(java.lang.String newLocalPatternChars)
Sets localized date-time pattern characters. For example: 'u', 't', etc.
Parameters:
newLocalPatternChars - the new localized date-time pattern characters.

clone

public java.lang.Object clone()
Overrides Cloneable
Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Override hashCode. Generates a hash code for the DateFormatSymbols object.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Override equals
Overrides:
equals in class java.lang.Object

constructCalendarSpecific

protected void constructCalendarSpecific(java.util.ResourceBundle bundle)
Given a resource bundle specific to the given Calendar class, initialize this object. Member variables will have already been initialized using the default mechanism, so only those that differ from or supplement the standard resource data need be handled here. If subclasses override this method, they should call super.constructCalendarSpecific(bundle) as needed to handle the "DayNames", "DayAbbreviations", "MonthNames", "MonthAbbreviations", and "Eras" resource data.

getDateFormatBundle

public static java.util.ResourceBundle getDateFormatBundle(java.lang.Class calendarClass,
                                                           java.util.Locale locale)
                                                    throws java.util.MissingResourceException
Find the ResourceBundle containing the date format information for a specified calendar subclass in a given locale.

The resource bundle name is based on the calendar's fully-specified class name, with ".resources" inserted at the end of the package name (just before the class name) and "Symbols" appended to the end. For example, the bundle corresponding to "com.ibm.util.HebrewCalendar" is "com.ibm.util.resources.HebrewCalendarSymbols".


getDateFormatBundle

public static java.util.ResourceBundle getDateFormatBundle(Calendar cal,
                                                           java.util.Locale locale)
                                                    throws java.util.MissingResourceException


Copyright (c) 1998-2000 IBM Corporation and others.