Java Code Examples for sun.util.calendar.Era#getName()
The following examples show how to use
sun.util.calendar.Era#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JapaneseImperialCalendar.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 2
Source File: JapaneseImperialCalendar.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 3
Source File: JapaneseImperialCalendar.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 4
Source File: JapaneseImperialCalendar.java From Java8CN with Apache License 2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 5
Source File: JapaneseImperialCalendar.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 6
Source File: JapaneseImperialCalendar.java From JDKSourceCode1.8 with MIT License | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 7
Source File: JapaneseImperialCalendar.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 8
Source File: JapaneseImperialCalendar.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 9
Source File: JapaneseImperialCalendar.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 10
Source File: JapaneseImperialCalendar.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 11
Source File: JapaneseImperialCalendar.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null, then // try to get its name or abbreviation from the Era instance. if (name == null && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 12
Source File: CalendarNameProviderImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; } if (value < 0 || value > strings.length) { return null; } else if (value == strings.length) { if (field == ERA && "japanese".equals(calendarType)) { // get the supplemental era, if any, specified through // the property "jdk.calendar.japanese.supplemental.era" // which is always the last element. Era[] jeras = CalendarSystem.forName("japanese").getEras(); if (jeras.length == value) { Era supEra = jeras[value - 1]; // 0-based index return style == LONG ? supEra.getName() : supEra.getAbbreviation(); } } return null; } name = strings[value]; // If name is empty in standalone, try its `format' style. if (name.length() == 0 && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, getBaseStyle(style), locale); } } } return name; }
Example 13
Source File: JapaneseImperialCalendar.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null or empty, then // try to get its name or abbreviation from the Era instance. if ((name == null || name.isEmpty()) && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 14
Source File: JapaneseImperialCalendar.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null or empty, then // try to get its name or abbreviation from the Era instance. if ((name == null || name.isEmpty()) && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 15
Source File: JapaneseImperialCalendar.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null or empty, then // try to get its name or abbreviation from the Era instance. if ((name == null || name.isEmpty()) && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 16
Source File: JapaneseImperialCalendar.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public String getDisplayName(int field, int style, Locale locale) { if (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) { return null; } int fieldValue = get(field); // "GanNen" is supported only in the LONG style. if (field == YEAR && (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) { return null; } String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, fieldValue, style, locale); // If the ERA value is null or empty, then // try to get its name or abbreviation from the Era instance. if ((name == null || name.isEmpty()) && field == ERA && fieldValue < eras.length) { Era era = eras[fieldValue]; name = (style == SHORT) ? era.getAbbreviation() : era.getName(); } return name; }
Example 17
Source File: CalendarNameProviderImpl.java From Bytecoder with Apache License 2.0 | 4 votes |
public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); // If standalone names are requested and no "standalone." resources are found, // try the default ones instead. if (strings == null && key.indexOf("standalone.") != -1) { key = key.replaceFirst("standalone.", ""); strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); } if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; } if (value < 0) { return null; } else if (value >= strings.length) { if (field == ERA && "japanese".equals(calendarType)) { Era[] jeras = CalendarSystem.forName("japanese").getEras(); if (value <= jeras.length) { // Localized era name could not be retrieved from this provider. // This can occur either for Reiwa or SupEra. // // If it's CLDR provider, try COMPAT first, which is guaranteed to have // the name for Reiwa. if (type == LocaleProviderAdapter.Type.CLDR) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE, calendarType, field, style, javatime); strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); } if (strings == null || value >= strings.length) { // Get the default name for SupEra Era supEra = jeras[value - 1]; // 0-based index if (javatime) { return getBaseStyle(style) == NARROW_FORMAT ? supEra.getAbbreviation() : supEra.getName(); } else { return (style & LONG) != 0 ? supEra.getName() : supEra.getAbbreviation(); } } } else { return null; } } else { return null; } } name = strings[value]; // If name is empty in standalone, try its `format' style. if (name.isEmpty() && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, getBaseStyle(style), locale); } } } return name; }
Example 18
Source File: CalendarNameProviderImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; } if (value < 0) { return null; } else if (value >= strings.length) { if (field == ERA && "japanese".equals(calendarType)) { Era[] jeras = CalendarSystem.forName("japanese").getEras(); if (value <= jeras.length) { // Localized era name could not be retrieved from this provider. // This can occur either for Reiwa or SupEra. // // If it's CLDR provider, try COMPAT first, which is guaranteed to have // the name for Reiwa. if (type == LocaleProviderAdapter.Type.CLDR) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE, calendarType, field, style, javatime); strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); } if (strings == null || value >= strings.length) { // Get the default name for SupEra Era supEra = jeras[value - 1]; // 0-based index if (javatime) { return getBaseStyle(style) == NARROW_FORMAT ? supEra.getAbbreviation() : supEra.getName(); } else { return (style & LONG) != 0 ? supEra.getName() : supEra.getAbbreviation(); } } } else { return null; } } else { return null; } } name = strings[value]; // If name is empty in standalone, try its `format' style. if (name.length() == 0 && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, getBaseStyle(style), locale); } } } return name; }
Example 19
Source File: CalendarNameProviderImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; } if (value < 0) { return null; } else if (value >= strings.length) { if (field == ERA && "japanese".equals(calendarType)) { Era[] jeras = CalendarSystem.forName("japanese").getEras(); if (value <= jeras.length) { // Localized era name could not be retrieved from this provider. // This can occur either for Reiwa or SupEra. // // If it's CLDR provider, try COMPAT first, which is guaranteed to have // the name for Reiwa. if (type == LocaleProviderAdapter.Type.CLDR) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE, calendarType, field, style, javatime); strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); } if (strings == null || value >= strings.length) { // Get the default name for SupEra Era supEra = jeras[value - 1]; // 0-based index if (javatime) { return getBaseStyle(style) == NARROW_FORMAT ? supEra.getAbbreviation() : supEra.getName(); } else { return (style & LONG) != 0 ? supEra.getName() : supEra.getAbbreviation(); } } } else { return null; } } else { return null; } } name = strings[value]; // If name is empty in standalone, try its `format' style. if (name.length() == 0 && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, getBaseStyle(style), locale); } } } return name; }
Example 20
Source File: CalendarNameProviderImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; } if (value < 0) { return null; } else if (value >= strings.length) { if (field == ERA && "japanese".equals(calendarType)) { Era[] jeras = CalendarSystem.forName("japanese").getEras(); if (value <= jeras.length) { // Localized era name could not be retrieved from this provider. // This can occur either for Reiwa or SupEra. // // If it's CLDR provider, try COMPAT first, which is guaranteed to have // the name for Reiwa. if (type == LocaleProviderAdapter.Type.CLDR) { lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale); key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE, calendarType, field, style, javatime); strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); } if (strings == null || value >= strings.length) { // Get the default name for SupEra Era supEra = jeras[value - 1]; // 0-based index if (javatime) { return getBaseStyle(style) == NARROW_FORMAT ? supEra.getAbbreviation() : supEra.getName(); } else { return (style & LONG) != 0 ? supEra.getName() : supEra.getAbbreviation(); } } } else { return null; } } else { return null; } } name = strings[value]; // If name is empty in standalone, try its `format' style. if (name.length() == 0 && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, getBaseStyle(style), locale); } } } return name; }