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

Print this page

        

@@ -52,10 +52,11 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import sun.util.calendar.ZoneInfo;
 import sun.util.resources.LocaleData;
 import sun.util.resources.OpenListResourceBundle;
+import sun.util.resources.ParallelListResourceBundle;
 import sun.util.resources.TimeZoneNamesBundle;
 
 /**
  * Central accessor to locale-dependent resources for JRE/CLDR provider adapters.
  *

@@ -329,10 +330,29 @@
         }
 
         return names;
     }
 
+    String[] getJavaTimeNames(String key) {
+        String[] names = null;
+        String cacheKey = CALENDAR_NAMES + key;
+
+        removeEmptyReferences();
+        ResourceReference data = cache.get(cacheKey);
+
+        if (data == null || ((names = (String[]) data.get()) == null)) {
+            ResourceBundle rb = getJavaTimeFormatData();
+            if (rb.containsKey(key)) {
+                names = rb.getStringArray(key);
+                cache.put(cacheKey,
+                          new ResourceReference(cacheKey, (Object) names, referenceQueue));
+            }
+        }
+
+        return names;
+    }
+
     public String getDateTimePattern(int timeStyle, int dateStyle, Calendar cal) {
         if (cal == null) {
             cal = Calendar.getInstance(locale);
         }
         return getDateTimePattern(null, timeStyle, dateStyle, cal.getCalendarType());

@@ -348,11 +368,11 @@
      * @return the pattern string
      */
     public String getCldrDateTimePattern(int timeStyle, int dateStyle, String calType) {
         calType = CalendarDataUtility.normalizeCalendarType(calType);
         String pattern;
-        pattern = getDateTimePattern("cldr.", timeStyle, dateStyle, calType);
+        pattern = getDateTimePattern("java.time.", timeStyle, dateStyle, calType);
         if (pattern == null) {
             pattern = getDateTimePattern(null, timeStyle, dateStyle, calType);
         }
         return pattern;
     }

@@ -428,12 +448,16 @@
     /**
      * Returns the FormatData resource bundle of this LocaleResources.
      * The FormatData should be used only for accessing extra
      * resources required by JSR 310.
      */
-    public ResourceBundle getFormatData() {
-        return localeData.getDateFormatData(locale);
+    public ResourceBundle getJavaTimeFormatData() {
+        ResourceBundle rb = localeData.getDateFormatData(locale);
+        if (rb instanceof ParallelListResourceBundle) {
+            localeData.setSupplementary((ParallelListResourceBundle) rb);
+        }
+        return rb;
     }
 
     private String getDateTimePattern(String prefix, String key, int styleIndex, String calendarType) {
         StringBuilder sb = new StringBuilder();
         if (prefix != null) {

@@ -449,11 +473,11 @@
         removeEmptyReferences();
         ResourceReference data = cache.get(cacheKey);
         Object value = NULLOBJECT;
 
         if (data == null || ((value = data.get()) == null)) {
-            ResourceBundle r = localeData.getDateFormatData(locale);
+            ResourceBundle r = (prefix != null) ? getJavaTimeFormatData() : localeData.getDateFormatData(locale);
             if (r.containsKey(resourceKey)) {
                 value = r.getStringArray(resourceKey);
             } else {
                 assert !resourceKey.equals(key);
                 if (r.containsKey(key)) {