public abstract class CalendarNameProvider extends LocaleServiceProvider
Calendar field values.
Calendar types are used to specify calendar systems for which the getDisplayName and getDisplayNames methods provide calendar field value names. See Calendar for details.
Calendar Fields
Calendar fields are specified with the constants defined in Calendar. The following are calendar-common fields and their values to be supported for each calendar system.
| Field | Value | Description |
|---|---|---|
Calendar |
Calendar to Calendar |
Month numbering is 0-based (e.g., 0 - January, ..., 11 - December). Some calendar systems have 13 months. Month names need to be supported in both the formatting and stand-alone forms if required by the supported locales. If there's no distinction in the two forms, the same names should be returned in both of the forms. |
Calendar |
Calendar to Calendar |
Day-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday, ..., 7 - Saturday). |
Calendar |
Calendar to Calendar |
0 - AM, 1 - PM |
The following are calendar-specific fields and their values to be supported.
| Calendar Type | Field | Value | Description |
|---|---|---|---|
"gregory" |
Calendar |
0 | GregorianCalendar (BCE) |
| 1 | GregorianCalendar (CE) |
||
"buddhist" |
Calendar |
0 | BC (BCE) |
| 1 | B.E. (Buddhist Era) | ||
"japanese" |
Calendar |
0 | Seireki (Before Meiji) |
| 1 | Meiji | ||
| 2 | Taisho | ||
| 3 | Showa | ||
| 4 | Heisei | ||
Calendar |
1 | the first year in each era. It should be returned when a long style (Calendar or Calendar) is specified. See also the Year representation in SimpleDateFormat. |
|
"roc" |
Calendar |
0 | Before R.O.C. |
| 1 | R.O.C. | ||
"islamic" |
Calendar |
0 | Before AH |
| 1 | Anno Hijrah (AH) |
Calendar field value names for "gregory" must be consistent with the date-time symbols provided by DateFormatSymbolsProvider.
Time zone names are supported by TimeZoneNameProvider.
CalendarDataProvider,
Locale.getUnicodeLocaleType(String)
| Modifier | Constructor and Description |
|---|---|
protected |
CalendarNameProvider()
Sole constructor.
|
| Modifier and Type | Method and Description |
|---|---|
abstract String |
getDisplayName(String
Returns the string representation (display name) of the calendar
field value in the given
style and
locale.
|
abstract Map |
getDisplayNames(String
Returns a
Map containing all string representations (display names) of the
Calendar
field in the given
style and
locale and their corresponding field values.
|
getAvailableLocales, isSupportedLocaleprotected CalendarNameProvider()
public abstract StringgetDisplayName(String calendarType, int field, int value, int style, Locale locale)
field value in the given
style and
locale. If no string representation is applicable,
null is returned.
field is a Calendar field index, such as Calendar. The time zone fields, Calendar and Calendar, are not supported by this method. null must be returned if any time zone fields are specified.
value is the numeric representation of the field value. For example, if field is Calendar, the valid values are Calendar to Calendar (inclusive).
style gives the style of the string representation. It is one of Calendar (SHORT), Calendar, Calendar (LONG), Calendar, Calendar, or Calendar.
For example, the following call will return "Sunday".
getDisplayName("gregory", Calendar.DAY_OF_WEEK, Calendar.SUNDAY,
Calendar.LONG_STANDALONE, Locale.ENGLISH);
calendarType - the calendar type. (Any calendar type given by
locale is ignored.)
field - the
Calendar field index, such as
Calendar.DAY_OF_WEEK
value - the value of the
Calendar field, such as
Calendar.MONDAY
style - the string representation style: one of
Calendar.SHORT_FORMAT (
SHORT),
Calendar.SHORT_STANDALONE ,
Calendar.LONG_FORMAT (
LONG),
Calendar.LONG_STANDALONE ,
Calendar.NARROW_FORMAT , or
Calendar.NARROW_STANDALONE
locale - the desired locale
field value, or
null if the string representation is not applicable or the given calendar type is unknown
IllegalArgumentException - if
field or
style is invalid
NullPointerException - if
locale is
null
TimeZoneNameProvider,
Calendar.get(int) ,
Calendar.getDisplayName(int, int, Locale)
public abstract Map<String ,Integer > getDisplayNames(String calendarType, int field, int style, Locale locale)
Map containing all string representations (display names) of the
Calendar
field in the given
style and
locale and their corresponding field values.
field is a Calendar field index, such as Calendar. The time zone fields, Calendar and Calendar, are not supported by this method. null must be returned if any time zone fields are specified.
style gives the style of the string representation. It must be one of Calendar, Calendar (SHORT), Calendar, Calendar (LONG), Calendar, Calendar, or Calendar. Note that narrow names may not be unique due to use of single characters, such as "S" for Sunday and Saturday, and that no narrow names are included in that case.
For example, the following call will return a Map containing "January" to Calendar, "Jan" to Calendar, "February" to Calendar, "Feb" to Calendar, and so on.
getDisplayNames("gregory", Calendar.MONTH, Calendar.ALL_STYLES, Locale.ENGLISH);
calendarType - the calendar type. (Any calendar type given by
locale is ignored.)
field - the calendar field for which the display names are returned
style - the style applied to the display names; one of
Calendar.ALL_STYLES ,
Calendar.SHORT_FORMAT (
SHORT),
Calendar.SHORT_STANDALONE ,
Calendar.LONG_FORMAT (
LONG),
Calendar.LONG_STANDALONE ,
Calendar.NARROW_FORMAT , or
Calendar.NARROW_STANDALONE
locale - the desired locale
Map containing all display names of
field in
style and
locale and their
field values, or
null if no display names are defined for
field
NullPointerException - if
locale is
null
Calendar.getDisplayNames(int, int, Locale)