|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.icu.text.DateFormatSymbols
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.
DateFormat
,
SimpleDateFormat
,
SimpleTimeZone
, Serialized FormConstructor 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 |
public DateFormatSymbols()
java.util.MissingResourceException
- if the resources for the default locale cannot be
found or cannot be loaded.public DateFormatSymbols(java.util.Locale locale)
java.util.MissingResourceException
- if the resources for the specified locale cannot be
found or cannot be loaded.public DateFormatSymbols(Calendar cal, java.util.Locale locale)
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.icu.util.HebrewCalendar"
is "com.ibm.icu.impl.data.HebrewCalendarSymbols".
Within the ResourceBundle, this method searches for five keys:
DAY_OF_WEEK
field. Even though
DAY_OF_WEEK
starts with SUNDAY
= 1,
This array is 0-based; the name for Sunday goes in the
first position, at index 0. If this key is not found
in the bundle, the day names are inherited from the
default DateFormatSymbols
for the requested locale.
DateFormatSymbols
for the locale.
MONTH
field. If this key is not found
in the bundle, the month names are inherited from the
default DateFormatSymbols
for the requested locale.
DateFormatSymbols
for the locale.
ERA
field. If this key is not found
in the bundle, the era names are inherited from the
default DateFormatSymbols
for the requested locale.
cal
- The calendar system whose date format symbols are desired.locale
- The locale whose symbols are desired.DateFormatSymbols(java.util.Locale)
public DateFormatSymbols(java.lang.Class calendarClass, java.util.Locale locale)
public DateFormatSymbols(java.util.ResourceBundle bundle, java.util.Locale locale)
DateFormatSymbols()
Method Detail |
public java.lang.String[] getEras()
public void setEras(java.lang.String[] newEras)
newEras
- the new era strings.public java.lang.String[] getMonths()
public void setMonths(java.lang.String[] newMonths)
newMonths
- the new month strings.public java.lang.String[] getShortMonths()
public void setShortMonths(java.lang.String[] newShortMonths)
newShortMonths
- the new short month strings.public java.lang.String[] getWeekdays()
Calendar.SUNDAY
,
Calendar.MONDAY
, etc. to index the result array.public void setWeekdays(java.lang.String[] newWeekdays)
newWeekdays
- the new weekday strings. The array should
be indexed by Calendar.SUNDAY
,
Calendar.MONDAY
, etc.public java.lang.String[] getShortWeekdays()
Calendar.SUNDAY
,
Calendar.MONDAY
, etc. to index the result array.public void setShortWeekdays(java.lang.String[] newShortWeekdays)
newShortWeekdays
- the new short weekday strings. The array should
be indexed by Calendar.SUNDAY
,
Calendar.MONDAY
, etc.public java.lang.String[] getAmPmStrings()
public void setAmPmStrings(java.lang.String[] newAmpms)
newAmpms
- the new ampm strings.public java.lang.String[][] getZoneStrings()
public void setZoneStrings(java.lang.String[][] newZoneStrings)
newZoneStrings
- the new timezone strings.public java.lang.String getLocalPatternChars()
public void setLocalPatternChars(java.lang.String newLocalPatternChars)
newLocalPatternChars
- the new localized date-time
pattern characters.public java.lang.Object clone()
clone
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
protected void constructCalendarSpecific(java.util.ResourceBundle bundle)
super.constructCalendarSpecific(bundle)
as needed to
handle the "DayNames", "DayAbbreviations", "MonthNames",
"MonthAbbreviations", and "Eras" resource data.public static java.util.ResourceBundle getDateFormatBundle(java.lang.Class calendarClass, java.util.Locale locale) throws java.util.MissingResourceException
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.icu.util.HebrewCalendar" is "com.ibm.icu.impl.data.HebrewCalendarSymbols".
public static java.util.ResourceBundle getDateFormatBundle(Calendar cal, java.util.Locale locale) throws java.util.MissingResourceException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |