src/share/classes/java/util/Calendar.java

Print this page
rev 6668 : imported patch 8008576

*** 55,64 **** --- 55,66 ---- import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.util.BuddhistCalendar; import sun.util.calendar.ZoneInfo; import sun.util.locale.provider.CalendarDataUtility; + import sun.util.locale.provider.LocaleProviderAdapter; + import sun.util.spi.CalendarProvider; /** * The <code>Calendar</code> class is an abstract class that provides methods * for converting between a specific instant in time and a set of {@link * #fields calendar fields} such as <code>YEAR</code>, <code>MONTH</code>,
*** 1606,1618 **** * * @return a Calendar. */ public static Calendar getInstance() { ! Calendar cal = createCalendar(TimeZone.getDefaultRef(), Locale.getDefault(Locale.Category.FORMAT)); ! cal.sharedZone = true; ! return cal; } /** * Gets a calendar using the specified time zone and default locale. * The <code>Calendar</code> returned is based on the current time --- 1608,1618 ---- * * @return a Calendar. */ public static Calendar getInstance() { ! return createCalendar(TimeZone.getDefault(), Locale.getDefault(Locale.Category.FORMAT)); } /** * Gets a calendar using the specified time zone and default locale. * The <code>Calendar</code> returned is based on the current time
*** 1635,1647 **** * @param aLocale the locale for the week data * @return a Calendar. */ public static Calendar getInstance(Locale aLocale) { ! Calendar cal = createCalendar(TimeZone.getDefaultRef(), aLocale); ! cal.sharedZone = true; ! return cal; } /** * Gets a calendar with the specified time zone and locale. * The <code>Calendar</code> returned is based on the current time --- 1635,1645 ---- * @param aLocale the locale for the week data * @return a Calendar. */ public static Calendar getInstance(Locale aLocale) { ! return createCalendar(TimeZone.getDefault(), aLocale); } /** * Gets a calendar with the specified time zone and locale. * The <code>Calendar</code> returned is based on the current time
*** 1658,1667 **** --- 1656,1676 ---- } private static Calendar createCalendar(TimeZone zone, Locale aLocale) { + CalendarProvider provider = + LocaleProviderAdapter.getAdapter(CalendarProvider.class, aLocale) + .getCalendarProvider(); + if (provider != null) { + try { + return provider.getInstance(zone, aLocale); + } catch (IllegalArgumentException iae) { + // fall back to the default instantiation + } + } + Calendar cal = null; if (aLocale.hasExtensions()) { String caltype = aLocale.getUnicodeLocaleType("ca"); if (caltype != null) {