publicstatic Locale getDefault(Locale.Category category){ // do not synchronize this method - see 4071298 switch (category) { case DISPLAY: if (defaultDisplayLocale == null) { synchronized(Locale.class) { if (defaultDisplayLocale == null) { defaultDisplayLocale = initDefault(category); } } } return defaultDisplayLocale; case FORMAT: if (defaultFormatLocale == null) { synchronized(Locale.class) { if (defaultFormatLocale == null) { defaultFormatLocale = initDefault(category); } } } return defaultFormatLocale; default: assertfalse: "Unknown Category"; } return getDefault(); }
privatestatic 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) { switch (caltype) { case"buddhist": cal = new BuddhistCalendar(zone, aLocale); break; case"japanese": cal = new JapaneseImperialCalendar(zone, aLocale); break; case"gregory": cal = new GregorianCalendar(zone, aLocale); break; } } } if (cal == null) { // If no known calendar type is explicitly specified, // perform the traditional way to create a Calendar: // create a BuddhistCalendar for th_TH locale, // a JapaneseImperialCalendar for ja_JP_JP locale, or // a GregorianCalendar for any other locales. // NOTE: The language, country and variant strings are interned. if (aLocale.getLanguage() == "th" && aLocale.getCountry() == "TH") { cal = new BuddhistCalendar(zone, aLocale); } elseif (aLocale.getVariant() == "JP" && aLocale.getLanguage() == "ja" && aLocale.getCountry() == "JP") { cal = new JapaneseImperialCalendar(zone, aLocale); } else { cal = new GregorianCalendar(zone, aLocale); } } return cal; }
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !