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

Print this page
rev 6352 : imported patch 7162007

@@ -26,11 +26,10 @@
 
 import static java.util.Calendar.*;
 import java.util.Comparator;
 import java.util.Locale;
 import java.util.Map;
-import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.spi.CalendarNameProvider;
 
 /**

@@ -52,14 +51,12 @@
     @Override
     public String getDisplayName(String calendarType, int field, int value, int style, Locale locale) {
         String name = null;
         String key = getResourceKey(calendarType, field, style);
         if (key != null) {
-            ResourceBundle rb = LocaleProviderAdapter.forType(type).getLocaleData().getDateFormatData(locale);
-            if (rb.containsKey(key)) {
-                String[] strings = rb.getStringArray(key);
-                if (strings.length > 0) {
+            String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key);
+            if (strings != null && strings.length > 0) {
                     if (field == DAY_OF_WEEK || field == YEAR) {
                         --value;
                     }
                     name = strings[value];
                     // If name is empty in standalone, try its `format' style.

@@ -70,11 +67,10 @@
                                               getBaseStyle(style),
                                               locale);
                     }
                 }
             }
-        }
         return name;
     }
 
     private static int[] REST_OF_STYLES = {
         SHORT_STANDALONE, LONG_FORMAT, LONG_STANDALONE,

@@ -98,13 +94,12 @@
     private Map<String, Integer> getDisplayNamesImpl(String calendarType, int field,
                                                      int style, Locale locale) {
         String key = getResourceKey(calendarType, field, style);
         Map<String, Integer> map = new TreeMap<>(LengthBasedComparator.INSTANCE);
         if (key != null) {
-            ResourceBundle rb = LocaleProviderAdapter.forType(type).getLocaleData().getDateFormatData(locale);
-            if (rb.containsKey(key)) {
-                String[] strings = rb.getStringArray(key);
+            String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key);
+            if (strings != null) {
                 if (!hasDuplicates(strings)) {
                     if (field == YEAR) {
                         if (strings.length > 0) {
                             map.put(strings[0], 1);
                         }