Search in sources :

Example 1 with DateFormatSymbolsProvider

use of java.text.spi.DateFormatSymbolsProvider in project jdk8u_jdk by JetBrains.

the class DateFormatSymbols method getProviderInstance.

private static DateFormatSymbols getProviderInstance(Locale locale) {
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
    DateFormatSymbolsProvider provider = adapter.getDateFormatSymbolsProvider();
    DateFormatSymbols dfsyms = provider.getInstance(locale);
    if (dfsyms == null) {
        provider = LocaleProviderAdapter.forJRE().getDateFormatSymbolsProvider();
        dfsyms = provider.getInstance(locale);
    }
    return dfsyms;
}
Also used : LocaleProviderAdapter(sun.util.locale.provider.LocaleProviderAdapter) DateFormatSymbolsProvider(java.text.spi.DateFormatSymbolsProvider)

Example 2 with DateFormatSymbolsProvider

use of java.text.spi.DateFormatSymbolsProvider in project jdk8u_jdk by JetBrains.

the class HostLocaleProviderAdapterImpl method getDateFormatSymbolsProvider.

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);
            if (ref == null || (dfs = ref.get()) == null) {
                dfs = new DateFormatSymbols(locale);
                String langTag = removeExtensions(locale).toLanguageTag();
                dfs.setAmPmStrings(getAmPmStrings(langTag, dfs.getAmPmStrings()));
                dfs.setEras(getEras(langTag, dfs.getEras()));
                dfs.setMonths(getMonths(langTag, dfs.getMonths()));
                dfs.setShortMonths(getShortMonths(langTag, dfs.getShortMonths()));
                dfs.setWeekdays(getWeekdays(langTag, dfs.getWeekdays()));
                dfs.setShortWeekdays(getShortWeekdays(langTag, dfs.getShortWeekdays()));
                ref = new SoftReference<>(dfs);
                dateFormatSymbolsCache.put(locale, ref);
            }
            return (DateFormatSymbols) dfs.clone();
        }
    };
}
Also used : Locale(java.util.Locale) DateFormatSymbolsProvider(java.text.spi.DateFormatSymbolsProvider) DateFormatSymbols(java.text.DateFormatSymbols)

Aggregations

DateFormatSymbolsProvider (java.text.spi.DateFormatSymbolsProvider)2 DateFormatSymbols (java.text.DateFormatSymbols)1 Locale (java.util.Locale)1 LocaleProviderAdapter (sun.util.locale.provider.LocaleProviderAdapter)1