src/share/classes/java/time/format/DateTimeTextProvider.java

Print this page

        

*** 193,203 **** fieldIndex = Calendar.AM_PM; fieldValue = (int) value; } else { return null; } ! return CalendarDataUtility.retrieveCldrFieldValueName( chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale); } /** * Gets an iterator of text to field for the specified field, locale and style --- 193,203 ---- fieldIndex = Calendar.AM_PM; fieldValue = (int) value; } else { return null; } ! return CalendarDataUtility.retrieveJavaTimeFieldValueName( chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale); } /** * Gets an iterator of text to field for the specified field, locale and style
*** 264,274 **** default: return null; } int calendarStyle = (style == null) ? Calendar.ALL_STYLES : style.toCalendarStyle(); ! Map<String, Integer> map = CalendarDataUtility.retrieveCldrFieldValueNames( chrono.getCalendarType(), fieldIndex, calendarStyle, locale); if (map == null) { return null; } List<Entry<String, Long>> list = new ArrayList<>(map.size()); --- 264,274 ---- default: return null; } int calendarStyle = (style == null) ? Calendar.ALL_STYLES : style.toCalendarStyle(); ! Map<String, Integer> map = CalendarDataUtility.retrieveJavaTimeFieldValueNames( chrono.getCalendarType(), fieldIndex, calendarStyle, locale); if (map == null) { return null; } List<Entry<String, Long>> list = new ArrayList<>(map.size());
*** 330,340 **** for (TextStyle textStyle : TextStyle.values()) { if (textStyle.isStandalone()) { // Stand-alone isn't applicable to era names. continue; } ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveCldrFieldValueNames( "gregory", Calendar.ERA, textStyle.toCalendarStyle(), locale); if (displayNames != null) { Map<Long, String> map = new HashMap<>(); for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long) entry.getValue(), entry.getKey()); --- 330,340 ---- for (TextStyle textStyle : TextStyle.values()) { if (textStyle.isStandalone()) { // Stand-alone isn't applicable to era names. continue; } ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( "gregory", Calendar.ERA, textStyle.toCalendarStyle(), locale); if (displayNames != null) { Map<Long, String> map = new HashMap<>(); for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long) entry.getValue(), entry.getKey());
*** 347,357 **** return new LocaleStore(styleMap); } if (field == MONTH_OF_YEAR) { for (TextStyle textStyle : TextStyle.values()) { ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveCldrFieldValueNames( "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale); Map<Long, String> map = new HashMap<>(); if (displayNames != null) { for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long) (entry.getValue() + 1), entry.getKey()); --- 347,357 ---- return new LocaleStore(styleMap); } if (field == MONTH_OF_YEAR) { for (TextStyle textStyle : TextStyle.values()) { ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale); Map<Long, String> map = new HashMap<>(); if (displayNames != null) { for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long) (entry.getValue() + 1), entry.getKey());
*** 360,370 **** } else { // Narrow names may have duplicated names, such as "J" for January, Jun, July. // Get names one by one in that case. for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) { String name; ! name = CalendarDataUtility.retrieveCldrFieldValueName( "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale); if (name == null) { break; } map.put((long) (month + 1), name); --- 360,370 ---- } else { // Narrow names may have duplicated names, such as "J" for January, Jun, July. // Get names one by one in that case. for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) { String name; ! name = CalendarDataUtility.retrieveJavaTimeFieldValueName( "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale); if (name == null) { break; } map.put((long) (month + 1), name);
*** 377,387 **** return new LocaleStore(styleMap); } if (field == DAY_OF_WEEK) { for (TextStyle textStyle : TextStyle.values()) { ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveCldrFieldValueNames( "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale); Map<Long, String> map = new HashMap<>(); if (displayNames != null) { for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long)toWeekDay(entry.getValue()), entry.getKey()); --- 377,387 ---- return new LocaleStore(styleMap); } if (field == DAY_OF_WEEK) { for (TextStyle textStyle : TextStyle.values()) { ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale); Map<Long, String> map = new HashMap<>(); if (displayNames != null) { for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long)toWeekDay(entry.getValue()), entry.getKey());
*** 390,400 **** } else { // Narrow names may have duplicated names, such as "S" for Sunday and Saturday. // Get names one by one in that case. for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) { String name; ! name = CalendarDataUtility.retrieveCldrFieldValueName( "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale); if (name == null) { break; } map.put((long)toWeekDay(wday), name); --- 390,400 ---- } else { // Narrow names may have duplicated names, such as "S" for Sunday and Saturday. // Get names one by one in that case. for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) { String name; ! name = CalendarDataUtility.retrieveJavaTimeFieldValueName( "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale); if (name == null) { break; } map.put((long)toWeekDay(wday), name);
*** 411,421 **** for (TextStyle textStyle : TextStyle.values()) { if (textStyle.isStandalone()) { // Stand-alone isn't applicable to AM/PM. continue; } ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveCldrFieldValueNames( "gregory", Calendar.AM_PM, textStyle.toCalendarStyle(), locale); if (displayNames != null) { Map<Long, String> map = new HashMap<>(); for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long) entry.getValue(), entry.getKey()); --- 411,421 ---- for (TextStyle textStyle : TextStyle.values()) { if (textStyle.isStandalone()) { // Stand-alone isn't applicable to AM/PM. continue; } ! Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( "gregory", Calendar.AM_PM, textStyle.toCalendarStyle(), locale); if (displayNames != null) { Map<Long, String> map = new HashMap<>(); for (Entry<String, Integer> entry : displayNames.entrySet()) { map.put((long) entry.getValue(), entry.getKey());
*** 476,486 **** */ @SuppressWarnings("unchecked") static <T> T getLocalizedResource(String key, Locale locale) { LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ! ResourceBundle rb = lr.getFormatData(); return rb.containsKey(key) ? (T) rb.getObject(key) : null; } /** * Stores the text for a single locale. --- 476,486 ---- */ @SuppressWarnings("unchecked") static <T> T getLocalizedResource(String key, Locale locale) { LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() .getLocaleResources(locale); ! ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey(key) ? (T) rb.getObject(key) : null; } /** * Stores the text for a single locale.