< prev index next >
src/java.base/share/classes/java/text/DateFormatSymbols.java
Print this page
rev 47480 : [mq]: 8176841
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -47,10 +47,11 @@
import java.util.Locale;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import sun.util.locale.provider.CalendarDataUtility;
import sun.util.locale.provider.LocaleProviderAdapter;
import sun.util.locale.provider.LocaleServiceProviderPool;
import sun.util.locale.provider.ResourceBundleBasedAdapter;
import sun.util.locale.provider.TimeZoneNameUtility;
@@ -80,10 +81,14 @@
* <pre>
* new SimpleDateFormat(aPattern, DateFormatSymbols.getInstance(aLocale)).
* </pre>
* </blockquote>
*
+ * <p>If the locale contains "rg" (region override)
+ * <a href="../util/Locale.html#def_locale_extension">Unicode extension</a>,
+ * the symbols are overriden for the designated region.
+ *
* <p>
* <code>DateFormatSymbols</code> objects are cloneable. When you obtain
* a <code>DateFormatSymbols</code> object, feel free to modify the
* date-time formatting data. For instance, you can replace the localized
* date-time format pattern characters with the ones that you feel easy
@@ -714,19 +719,22 @@
// Remove the empty SoftReference
cachedInstances.remove(locale, ref);
}
dfs = new DateFormatSymbols(false);
+ // check for region override
+ Locale override = CalendarDataUtility.findRegionOverride(locale).orElse(locale);
+
// Initialize the fields from the ResourceBundle for locale.
LocaleProviderAdapter adapter
- = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
+ = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, override);
// Avoid any potential recursions
if (!(adapter instanceof ResourceBundleBasedAdapter)) {
adapter = LocaleProviderAdapter.getResourceBundleBased();
}
ResourceBundle resource
- = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);
+ = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(override);
dfs.locale = locale;
// JRE and CLDR use different keys
// JRE: Eras, short.Eras and narrow.Eras
// CLDR: long.Eras, Eras and narrow.Eras
< prev index next >