- java.lang.Object
-
- java.util.spi.LocaleServiceProvider
-
- java.util.spi.CalendarNameProvider
-
public abstract class CalendarNameProvider extends LocaleServiceProvider
服务提供者的抽象类,提供Calendar字段值的本地化字符串表示形式(显示名称)。日历类型用于指定
getDisplayName和getDisplayNames方法为其提供日历字段值名称的日历系统。 有关详细信息,请参见Calendar.getCalendarType()。日历字段
日历字段使用
Field values Field Value DescriptionCalendar中定义的常量指定。 以下是日历 - 公共字段及其为每个日历系统支持的值。Calendar.MONTHCalendar.JANUARYtoCalendar.UNDECIMBERMonth 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_WEEKCalendar.SUNDAYtoCalendar.SATURDAYDay-of-week numbering is 1-based starting from Sunday (i.e., 1 - Sunday, ..., 7 - Saturday).Calendar.AM_PMCalendar.AMtoCalendar.PM0 - AM, 1 - PM以下是特定于日历的字段及其支持的值。
Calendar type and field values Calendar Type Field Value Description"gregory"Calendar.ERA0GregorianCalendar.BC(BCE) 1GregorianCalendar.AD(CE)"buddhist"Calendar.ERA0 BC (BCE) 1 B.E. (Buddhist Era)"japanese"Calendar.ERA0 Seireki (Before Meiji) 1 Meiji 2 Taisho 3 Showa 4 HeiseiCalendar.YEAR1 the first year in each era. It should be returned when a long style (Calendar.LONG_FORMATorCalendar.LONG_STANDALONE) is specified. See also the Year representation inSimpleDateFormat."roc"Calendar.ERA0 Before R.O.C. 1 R.O.C."islamic"Calendar.ERA0 Before AH 1 Anno Hijrah (AH)"gregory"日历字段值名称必须与"gregory"提供的日期时间符号一致 。TimeZoneNameProvider支持时区名称。- 从以下版本开始:
- 1.8
- 另请参见:
-
CalendarDataProvider,Locale.getUnicodeLocaleType(String)
-
-
构造方法摘要
构造方法 变量 构造器 描述 protectedCalendarNameProvider()唯一的构造函数。
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 abstract StringgetDisplayName(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字段给定style和locale及其相应的字段值。-
声明方法的类 java.util.spi.LocaleServiceProvider
getAvailableLocales, isSupportedLocale
-
-
-
-
方法详细信息
-
getDisplayName
public abstract String getDisplayName(String calendarType, int field, int value, int style, Locale locale)
返回给定style和locale日历field value的字符串表示形式(显示名称)。 如果没有适用的字符串表示形式,则返回null。字段是Calendar字段索引,例如Calendar.MONTH。 此方法不支持时区字段Calendar.ZONE_OFFSET和Calendar.DST_OFFSET。 如果指定了任何时区字段,则必须返回null。value是字段值的数字表示形式。 例如,如果字段是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给出的任何日历类型。) -
字段-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- 所需的区域设置 - 结果
-
如果字符串表示不适用或给定的日历类型未知,
nullfield value或null的字符串表示形式 - 异常
-
IllegalArgumentException- 如果字段或style无效 -
NullPointerException- 如果locale是null - 另请参见:
-
TimeZoneNameProvider,Calendar.get(int),Calendar.getDisplayName(int, int, Locale)
-
getDisplayNames
public abstract Map<String,Integer> getDisplayNames(String calendarType, int field, int style, Locale locale)
返回Map包含的所有字符串表示(显示名称)Calendar字段给定style和locale及其相应的字段值。字段是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给出的任何日历类型。) -
字段- 为其返回显示名称的日历字段 -
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及其字段值,或者null如果没有显示名称为定义字段 - 异常
-
NullPointerException- 如果locale是null - 另请参见:
-
Calendar.getDisplayNames(int, int, Locale)
-
-