public abstract class CalendarNameProvider extends LocaleServiceProvider
Calendar字段值的本地化字符串表示(显示名称)的服务提供者的抽象类。
日历类型用于指定getDisplayName和getDisplayNames方法提供日历字段值名称的日历系统。 详见Calendar.getCalendarType() 。
日历字段
日历字段由Calendar中定义的常量指定 。 以下是日历常用字段及其每个日历系统支持的值。
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 Description"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, isSupportedLocalepublic 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("gregory", Calendar.DAY_OF_WEEK, Calendar.SUNDAY,
Calendar.LONG_STANDALONE, Locale.ENGLISH);
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无效
NullPointerException - 如果
locale是
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包含的所有字符串表示(显示名称) 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("gregory", Calendar.MONTH, Calendar.ALL_STYLES, Locale.ENGLISH);
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包含的所有显示名称
field在
style和
locale及其
field值,或
null如果没有显示名称为定义
field
NullPointerException - 如果
locale是
null
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.