src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java

Print this page

        

@@ -51,19 +51,20 @@
     @Override
     public String getDisplayName(String calendarType, int field, int value, int style, Locale locale) {
         return getDisplayNameImpl(calendarType, field, value, style, locale, false);
     }
 
-    public String getCldrDisplayName(String calendarType, int field, int value, int style, Locale locale) {
+    public String getJavaTimeDisplayName(String calendarType, int field, int value, int style, Locale locale) {
         return getDisplayNameImpl(calendarType, field, value, style, locale, true);
     }
 
-    public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean cldr) {
+    public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) {
         String name = null;
-        String key = getResourceKey(calendarType, field, style, cldr);
+        String key = getResourceKey(calendarType, field, style, javatime);
         if (key != null) {
-            String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key);
+            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) {

@@ -102,22 +103,23 @@
         }
         return names.isEmpty() ? null : names;
     }
 
     // NOTE: This method should be used ONLY BY JSR 310 classes.
-    public Map<String, Integer> getCldrDisplayNames(String calendarType, int field, int style, Locale locale) {
+    public Map<String, Integer> getJavaTimeDisplayNames(String calendarType, int field, int style, Locale locale) {
         Map<String, Integer> names;
         names = getDisplayNamesImpl(calendarType, field, style, locale, true);
         return names.isEmpty() ? null : names;
     }
 
     private Map<String, Integer> getDisplayNamesImpl(String calendarType, int field,
-                                                     int style, Locale locale, boolean cldr) {
-        String key = getResourceKey(calendarType, field, style, cldr);
+                                                     int style, Locale locale, boolean javatime) {
+        String key = getResourceKey(calendarType, field, style, javatime);
         Map<String, Integer> map = new TreeMap<>(LengthBasedComparator.INSTANCE);
         if (key != null) {
-            String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key);
+            LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale);
+            String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key);
             if (strings != null) {
                 if (!hasDuplicates(strings)) {
                     if (field == YEAR) {
                         if (strings.length > 0) {
                             map.put(strings[0], 1);

@@ -218,22 +220,22 @@
             }
         }
         return false;
     }
 
-    private String getResourceKey(String type, int field, int style, boolean cldr) {
+    private String getResourceKey(String type, int field, int style, boolean javatime) {
         int baseStyle = getBaseStyle(style);
         boolean isStandalone = (style != baseStyle);
 
         if ("gregory".equals(type)) {
             type = null;
         }
         boolean isNarrow = (baseStyle == NARROW_FORMAT);
         StringBuilder key = new StringBuilder();
-        // If cldr is true, use prefix "cldr.".
-        if (cldr) {
-            key.append("cldr.");
+        // If cldr is true, use prefix "java.time.".
+        if (javatime) {
+            key.append("java.time.");
         }
         switch (field) {
         case ERA:
             if (type != null) {
                 key.append(type).append('.');

@@ -243,19 +245,19 @@
             } else {
                 // JRE and CLDR use different resource key conventions
                 // due to historical reasons. (JRE DateFormatSymbols.getEras returns
                 // abbreviations while other getShort*() return abbreviations.)
                 if (this.type == LocaleProviderAdapter.Type.JRE) {
-                    if (cldr) {
+                    if (javatime) {
                         if (baseStyle == LONG) {
                             key.append("long.");
                         }
                     }
                     if (baseStyle == SHORT) {
                         key.append("short.");
                     }
-                } else { // CLDR
+                } else { // this.type == LocaleProviderAdapter.Type.CLDR
                     if (baseStyle == LONG) {
                         key.append("long.");
                     }
                 }
             }