mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8206965: java/util/TimeZone/Bug8149452.java failed on de_DE and ja_JP locale
Generated display names for missing timezones at run time. Reviewed-by: naoto
This commit is contained in:
parent
6c703b8589
commit
50a3c19ffc
3 changed files with 42 additions and 33 deletions
|
@ -44,12 +44,14 @@ import java.lang.ref.ReferenceQueue;
|
|||
import java.lang.ref.SoftReference;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
@ -308,26 +310,37 @@ public class LocaleResources {
|
|||
Set<String> keyset = getZoneIDs();
|
||||
// Use a LinkedHashSet to preseve the order
|
||||
Set<String[]> value = new LinkedHashSet<>();
|
||||
Set<String> tzIds = new HashSet<>(Set.of(TimeZone.getAvailableIDs()));
|
||||
for (String key : keyset) {
|
||||
if (!key.startsWith(TZNB_EXCITY_PREFIX)) {
|
||||
value.add(rb.getStringArray(key));
|
||||
tzIds.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
// Add aliases data for CLDR
|
||||
if (type == LocaleProviderAdapter.Type.CLDR) {
|
||||
// Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
|
||||
// Add aliases data for CLDR
|
||||
Map<String, String> aliases = ZoneInfo.getAliasTable();
|
||||
for (String alias : aliases.keySet()) {
|
||||
if (!keyset.contains(alias)) {
|
||||
String tzid = aliases.get(alias);
|
||||
if (keyset.contains(tzid)) {
|
||||
String[] val = rb.getStringArray(tzid);
|
||||
val[0] = alias;
|
||||
// Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
|
||||
|
||||
// Add timezones which are not present in this keyset,
|
||||
// so that their fallback names will be generated at runtime.
|
||||
tzIds.stream().filter(i -> (!i.startsWith("Etc/GMT")
|
||||
&& !i.startsWith("GMT")
|
||||
&& !i.startsWith("SystemV")))
|
||||
.forEach(tzid -> {
|
||||
String[] val = new String[7];
|
||||
if (keyset.contains(tzid)) {
|
||||
val = rb.getStringArray(tzid);
|
||||
} else {
|
||||
String tz = aliases.get(tzid);
|
||||
if (keyset.contains(tz)) {
|
||||
val = rb.getStringArray(tz);
|
||||
}
|
||||
}
|
||||
val[0] = tzid;
|
||||
value.add(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return value.toArray(new String[0][]);
|
||||
}
|
||||
|
|
|
@ -604,6 +604,10 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
|
|||
{"Asia/Ashkhabad", TMT},
|
||||
{"Asia/Baghdad", ARAST},
|
||||
{"Asia/Bahrain", ARAST},
|
||||
{"Asia/Barnaul", new String[] {"Barnaul Standard Time", "GMT+07:00",
|
||||
"Barnaul Daylight Time", "GMT+07:00",
|
||||
"Barnaul Time" , "GMT+07:00"}},
|
||||
|
||||
{"Asia/Baku", new String[] {"Azerbaijan Time", "AZT",
|
||||
"Azerbaijan Summer Time", "AZST",
|
||||
"Azerbaijan Time", "AZT"}},
|
||||
|
@ -711,6 +715,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
|
|||
{"Asia/Tehran", IRT},
|
||||
{"Asia/Thimbu", BTT},
|
||||
{"Asia/Thimphu", BTT},
|
||||
{"Asia/Tomsk", new String[] {"Tomsk Standard Time", "GMT+07:00",
|
||||
"Tomsk Daylight Time", "GMT+07:00",
|
||||
"Tomsk Time" , "GMT+07:00"}},
|
||||
{"Asia/Ujung_Pandang", CIT},
|
||||
{"Asia/Ulaanbaatar", ULAT},
|
||||
{"Asia/Ulan_Bator", ULAT},
|
||||
|
@ -827,6 +834,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
|
|||
{"Europe/Jersey", GMTBST},
|
||||
{"Europe/Kaliningrad", EET},
|
||||
{"Europe/Kiev", EET},
|
||||
{"Europe/Kirov", new String[] {"Kirov Standard Time", "GMT+03:00",
|
||||
"Kirov Daylight Time", "GMT+03:00",
|
||||
"Kirov Time", "GMT+03:00"}},
|
||||
{"Europe/Lisbon", WET},
|
||||
{"Europe/Ljubljana", CET},
|
||||
{"Europe/London", GMTBST},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue