equal
deleted
inserted
replaced
49 import java.security.PrivilegedActionException; |
49 import java.security.PrivilegedActionException; |
50 import java.security.PrivilegedExceptionAction; |
50 import java.security.PrivilegedExceptionAction; |
51 import java.security.ProtectionDomain; |
51 import java.security.ProtectionDomain; |
52 import java.text.DateFormat; |
52 import java.text.DateFormat; |
53 import java.text.DateFormatSymbols; |
53 import java.text.DateFormatSymbols; |
|
54 import java.util.concurrent.ConcurrentHashMap; |
|
55 import java.util.concurrent.ConcurrentMap; |
54 import sun.util.BuddhistCalendar; |
56 import sun.util.BuddhistCalendar; |
55 import sun.util.calendar.ZoneInfo; |
57 import sun.util.calendar.ZoneInfo; |
56 import sun.util.resources.LocaleData; |
58 import sun.util.resources.LocaleData; |
57 |
59 |
58 /** |
60 /** |
835 |
837 |
836 /** |
838 /** |
837 * Cache to hold the firstDayOfWeek and minimalDaysInFirstWeek |
839 * Cache to hold the firstDayOfWeek and minimalDaysInFirstWeek |
838 * of a Locale. |
840 * of a Locale. |
839 */ |
841 */ |
840 private static Hashtable<Locale, int[]> cachedLocaleData = new Hashtable<Locale, int[]>(3); |
842 private static final ConcurrentMap<Locale, int[]> cachedLocaleData |
|
843 = new ConcurrentHashMap<Locale, int[]>(3); |
841 |
844 |
842 // Special values of stamp[] |
845 // Special values of stamp[] |
843 /** |
846 /** |
844 * The corresponding fields[] has no value. |
847 * The corresponding fields[] has no value. |
845 */ |
848 */ |
1020 // Calendar type is not specified. |
1023 // Calendar type is not specified. |
1021 // If the specified locale is a Thai locale, |
1024 // If the specified locale is a Thai locale, |
1022 // returns a BuddhistCalendar instance. |
1025 // returns a BuddhistCalendar instance. |
1023 if ("th".equals(aLocale.getLanguage()) |
1026 if ("th".equals(aLocale.getLanguage()) |
1024 && ("TH".equals(aLocale.getCountry()))) { |
1027 && ("TH".equals(aLocale.getCountry()))) { |
1025 cal = new BuddhistCalendar(zone, aLocale); |
1028 cal = new BuddhistCalendar(zone, aLocale); |
1026 } else { |
1029 } else { |
1027 cal = new GregorianCalendar(zone, aLocale); |
1030 cal = new GregorianCalendar(zone, aLocale); |
1028 } |
1031 } |
1029 } else if (caltype.equals("japanese")) { |
1032 } else if (caltype.equals("japanese")) { |
1030 cal = new JapaneseImperialCalendar(zone, aLocale); |
1033 cal = new JapaneseImperialCalendar(zone, aLocale); |
2586 if (data == null) { /* cache miss */ |
2589 if (data == null) { /* cache miss */ |
2587 ResourceBundle bundle = LocaleData.getCalendarData(desiredLocale); |
2590 ResourceBundle bundle = LocaleData.getCalendarData(desiredLocale); |
2588 data = new int[2]; |
2591 data = new int[2]; |
2589 data[0] = Integer.parseInt(bundle.getString("firstDayOfWeek")); |
2592 data[0] = Integer.parseInt(bundle.getString("firstDayOfWeek")); |
2590 data[1] = Integer.parseInt(bundle.getString("minimalDaysInFirstWeek")); |
2593 data[1] = Integer.parseInt(bundle.getString("minimalDaysInFirstWeek")); |
2591 cachedLocaleData.put(desiredLocale, data); |
2594 cachedLocaleData.putIfAbsent(desiredLocale, data); |
2592 } |
2595 } |
2593 firstDayOfWeek = data[0]; |
2596 firstDayOfWeek = data[0]; |
2594 minimalDaysInFirstWeek = data[1]; |
2597 minimalDaysInFirstWeek = data[1]; |
2595 } |
2598 } |
2596 |
2599 |