src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java

Print this page
rev 6663 : imported patch 8008576

*** 33,53 **** --- 33,56 ---- import java.text.SimpleDateFormat; import java.text.spi.DateFormatProvider; import java.text.spi.DateFormatSymbolsProvider; import java.text.spi.DecimalFormatSymbolsProvider; import java.text.spi.NumberFormatProvider; + import java.util.Calendar; import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle.Control; import java.util.Set; + import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.spi.CalendarDataProvider; import java.util.spi.CalendarNameProvider; + import sun.util.spi.CalendarProvider; /** * LocaleProviderdapter implementation for the Windows locale data. * * @author Naoto Sato
*** 171,200 **** public static DateFormatSymbolsProvider getDateFormatSymbolsProvider() { return new DateFormatSymbolsProvider() { @Override public Locale[] getAvailableLocales() { ! if (isSupportedLocale(Locale.getDefault(Locale.Category.FORMAT))) { ! return supportedLocale; } - return new Locale[0]; - } - @Override public boolean isSupportedLocale(Locale locale) { ! // Only supports the locale with Gregorian calendar ! if (supportedLocale.length != 0) { ! int calid = getCalendarID(locale.toLanguageTag()); ! if (calid > 0 && calid < calIDToLDML.length) { ! return calIDToLDML[calid].startsWith("gregory"); } - } - return false; - } - @Override public DateFormatSymbols getInstance(Locale locale) { DateFormatSymbols dfs; SoftReference<DateFormatSymbols> ref = dateFormatSymbolsCache.get(locale); --- 174,191 ---- public static DateFormatSymbolsProvider getDateFormatSymbolsProvider() { return new DateFormatSymbolsProvider() { @Override public Locale[] getAvailableLocales() { ! return getSupportedCalendarLocales(); } @Override public boolean isSupportedLocale(Locale locale) { ! return isSupportedCalendarLocale(locale); } @Override public DateFormatSymbols getInstance(Locale locale) { DateFormatSymbols dfs; SoftReference<DateFormatSymbols> ref = dateFormatSymbolsCache.get(locale);
*** 378,387 **** --- 369,400 ---- return null; } }; } + public static CalendarProvider getCalendarProvider() { + return new CalendarProvider() { + @Override + public Locale[] getAvailableLocales() { + return getSupportedCalendarLocales(); + } + + @Override + public boolean isSupportedLocale(Locale locale) { + return isSupportedCalendarLocale(locale); + } + + @Override + public Calendar getInstance(TimeZone zone, Locale locale) { + return new Calendar.Builder() + .setLocale(getCalendarLocale(locale)) + .setTimeZone(zone) + .build(); + } + }; + } + private static String convertDateTimePattern(String winPattern) { String ret = winPattern.replaceAll("dddd", "EEEE"); ret = ret.replaceAll("ddd", "EEE"); ret = ret.replaceAll("tt", "aa"); ret = ret.replaceAll("g", "GG");
*** 399,427 **** } return supportedLocale; } private static boolean isSupportedCalendarLocale(Locale locale) { - // special case for ja_JP_JP - if (JRELocaleConstants.JA_JP_JP.equals(locale)) { - return isJapaneseCalendar(); - } - Locale base = locale.stripExtensions(); if (!supportedLocaleSet.contains(base)) { return false; } ! String caltype = locale.getUnicodeLocaleType("ca"); ! if (caltype == null) { ! return true; ! } ! ! return caltype.equals( calIDToLDML[getCalendarID(locale.toLanguageTag())] ! .replaceFirst("_.*", "")); } private static Locale[] getSupportedNativeDigitLocales() { if (supportedLocale.length != 0 && supportedLocaleSet.contains(JRELocaleConstants.TH_TH) && isNativeDigit("th-TH")) { --- 412,437 ---- } return supportedLocale; } private static boolean isSupportedCalendarLocale(Locale locale) { Locale base = locale.stripExtensions(); if (!supportedLocaleSet.contains(base)) { return false; } ! String requestedCalType = locale.getUnicodeLocaleType("ca"); ! String nativeCalType = calIDToLDML[getCalendarID(locale.toLanguageTag())] ! .replaceFirst("_.*", ""); // remove locale part. ! ! if (requestedCalType == null) { ! return Calendar.getAvailableCalendarTypes().contains(nativeCalType); ! } else { ! return requestedCalType.equals(nativeCalType); } + } private static Locale[] getSupportedNativeDigitLocales() { if (supportedLocale.length != 0 && supportedLocaleSet.contains(JRELocaleConstants.TH_TH) && isNativeDigit("th-TH")) {