public abstract class CalendarNameProvider extends LocaleServiceProvider
Calendar
字段值。
日历类型用于指定日历系统,getDisplayName
和getDisplayNames
方法提供日历字段值的名称。看到Calendar.getCalendarType()
详情。
日历字段
日历字段中定义的常数指定Calendar
。以下是为每个日历系统支持的日历通用字段及其值。
Field | Value | 描述 |
---|---|---|
Calendar.MONTH |
Calendar.JANUARY to Calendar.UNDECIMBER |
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.DAY_OF_WEEK |
Calendar.SUNDAY to Calendar.SATURDAY |
Day-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday, ..., 7 - Saturday). |
Calendar.AM_PM |
Calendar.AM to Calendar.PM |
0 - AM, 1 - PM |
以下是要支持的日历特定字段和它们的值。
Calendar Type | Field | Value | 描述 |
---|---|---|---|
"gregory" |
Calendar.ERA |
0 | GregorianCalendar.BC (BCE) |
1 | GregorianCalendar.AD (CE) |
||
"buddhist" |
Calendar.ERA |
0 | BC (BCE) |
1 | B.E. (Buddhist Era) | ||
"japanese" |
Calendar.ERA |
0 | Seireki (Before Meiji) |
1 | Meiji | ||
2 | Taisho | ||
3 | Showa | ||
4 | Heisei | ||
Calendar.YEAR |
1 | the first year in each era. It should be returned when a long style (Calendar.LONG_FORMAT or Calendar.LONG_STANDALONE ) is specified. See also the Year representation in SimpleDateFormat . |
|
"roc" |
Calendar.ERA |
0 | Before R.O.C. |
1 | R.O.C. | ||
"islamic" |
Calendar.ERA |
0 | Before AH |
1 | Anno Hijrah (AH) |
对于"gregory"
日历字段值的名称必须与所提供的DateFormatSymbolsProvider
日期时间符号一致。
时区的名字都是由TimeZoneNameProvider
。
CalendarDataProvider
,
Locale.getUnicodeLocaleType(String)
Modifier | Constructor and Description |
---|---|
protected |
CalendarNameProvider()
唯一的构造函数。
|
Modifier and Type | Method and Description |
---|---|
abstract String |
getDisplayName(String calendarType, int field, int value, int style, Locale locale)
返回的字符串表示形式(显示名称)在给定的
style 和
locale 日历的
field value 。
|
abstract Map<String,Integer> |
getDisplayNames(String calendarType, int field, int style, Locale locale)
返回一个包含所有的字符串表示
Map (显示名称)的
Calendar
field 在给定的
style 和
locale 及其相应的字段值。
|
getAvailableLocales, isSupportedLocale
protected CalendarNameProvider()
public abstract String getDisplayName(String calendarType, int field, int value, int style, Locale locale)
style
和
locale
日历的
field value
。如果没有字符串表示形式是适用的,
null
返回。
field
是Calendar
字段索引,如Calendar.MONTH
。时区领域,Calendar.ZONE_OFFSET
和Calendar.DST_OFFSET
,此方法不支持。null
必须如果指定了时区字段返回。
value
的field
值的数字表示法。例如,如果field
是Calendar.DAY_OF_WEEK
,有效值是Calendar.SUNDAY
到Calendar.SATURDAY
(含)。
style
给出的字符串表示形式。这是一个Calendar.SHORT_FORMAT
(SHORT
),Calendar.SHORT_STANDALONE
,Calendar.LONG_FORMAT
(LONG
),Calendar.LONG_STANDALONE
,Calendar.NARROW_FORMAT
,或Calendar.NARROW_STANDALONE
。
例如,下面的调用将返回"Sunday"
。
getdisplayname(“格雷戈瑞”,calendar.day_of_week,calendar.sunday,calendar.long_standalone,现场英语);
calendarType
-日历类型。(任何日历式的
locale
被忽略。)
field
-
Calendar
字段索引,如
Calendar.DAY_OF_WEEK
value
的
Calendar field
的价值,如
Calendar.MONDAY
style
的字符串表示形式:一
Calendar.SHORT_FORMAT
(
SHORT
),
Calendar.SHORT_STANDALONE
,
Calendar.LONG_FORMAT
(
LONG
),
Calendar.LONG_STANDALONE
,
Calendar.NARROW_FORMAT
,或
Calendar.NARROW_STANDALONE
locale
-所需的现场
field value
的字符串表示形式,或
null
如果字符串表示不适用或给定的日历类型未知
IllegalArgumentException
-如果
field
或
style
无效
null
locale
NullPointerException
TimeZoneNameProvider
,
Calendar.get(int)
,
Calendar.getDisplayName(int, int, Locale)
public abstract Map<String,Integer> getDisplayNames(String calendarType, int field, int style, Locale locale)
Map
(显示名称)的
Calendar
field
在给定的
style
和
locale
及其相应的字段值。
field
是Calendar
字段索引,如Calendar.MONTH
。时区的领域,Calendar.ZONE_OFFSET
和Calendar.DST_OFFSET
,此方法不支持。null
必须如果指定了时区字段返回。
style
给出的字符串表示形式。它必须是一个Calendar.ALL_STYLES
,Calendar.SHORT_FORMAT
(SHORT
),Calendar.SHORT_STANDALONE
,Calendar.LONG_FORMAT
(LONG
),Calendar.LONG_STANDALONE
,Calendar.NARROW_FORMAT
,或Calendar.NARROW_STANDALONE
。请注意,狭窄的名字可能不是唯一的,由于使用单一的字符,如“S”为星期日和星期六,并没有狭窄的名称包括在这种情况下。
例如,下面的调用将返回一个Map
含"January"
到Calendar.JANUARY
,"Jan"
到Calendar.JANUARY
,"February"
到Calendar.FEBRUARY
,"Feb"
到Calendar.FEBRUARY
,等等。
getdisplaynames(“格雷戈瑞”,calendar.month,calendar.all_styles,现场。英语);
calendarType
-日历类型。(任何日历式的
locale
被忽略。)
field
-日历字段的显示名称返回
style
-用于显示名称的风格;一个
Calendar.ALL_STYLES
,
Calendar.SHORT_FORMAT
(
SHORT
),
Calendar.SHORT_STANDALONE
,
Calendar.LONG_FORMAT
(
LONG
),
Calendar.LONG_STANDALONE
,
Calendar.NARROW_FORMAT
,或
Calendar.NARROW_STANDALONE
locale
-所需的现场
Map
含在
style
和
locale
及其
field
值
field
所有显示的名称,或
null
如果没有显示名称被定义为
field
null
locale
NullPointerException
Calendar.getDisplayNames(int, int, Locale)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.