diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index de496b3f606b3..fb02fde5273fd 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -801,10 +801,7 @@ private static Map extractZoneNames(Map map, Str String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid)) .orElse(tzid); // Follow link, if needed - String tzLink = null; - for (var k = tzKey; tzdbLinks.containsKey(k);) { - k = tzLink = tzdbLinks.get(k); - } + String tzLink = getTZDBLink(tzKey); if (tzLink == null && tzdbLinks.containsValue(tzKey)) { // reverse link search // this is needed as in tzdb, "America/Buenos_Aires" links to @@ -833,7 +830,7 @@ private static Map extractZoneNames(Map map, Str } else { // TZDB short names tznames = Arrays.copyOf(tznames, tznames.length); - fillTZDBShortNames(tzid, tznames); + fillTZDBShortNames(tzKey, tznames); names.put(tzid, tznames); } } else { @@ -846,11 +843,17 @@ private static Map extractZoneNames(Map map, Str String metaKey = METAZONE_ID_PREFIX + meta; data = map.get(metaKey); if (data instanceof String[] tznames) { + boolean isDefZone = isDefaultZone(meta, tzKey); // TZDB short names - tznames = Arrays.copyOf((String[])names.getOrDefault(metaKey, tznames), 6); - fillTZDBShortNames(tzid, tznames); - // Keep the metazone prefix here. - names.putIfAbsent(metaKey, tznames); + tznames = isDefZone ? + Arrays.copyOf(tznames, 6) : + Arrays.copyOf((String[]) names.getOrDefault(metaKey, tznames), 6); + fillTZDBShortNames(tzKey, tznames); + if (!names.containsKey(metaKey) + // Default zone for a metazone always puts the names + || isDefZone) { + names.put(metaKey, tznames); + } names.put(tzid, meta); if (tzLink != null && availableIds.contains(tzLink)) { names.put(tzLink, meta); @@ -1504,12 +1507,12 @@ private static String flipIfNeeded(boolean inVanguard, String format) { * Fill the TZDB short names if there is no name provided by the CLDR */ private static void fillTZDBShortNames(String tzid, String[] names) { - var val = tzdbShortNamesMap.get(tzdbLinks.getOrDefault(tzid, tzid)); + var val = tzdbShortNamesMap.getOrDefault(tzid, tzdbShortNamesMap.get(getTZDBLink(tzid))); if (val != null) { var format = val.split(NBSP)[0]; var rule = val.split(NBSP)[1]; IntStream.of(1, 3, 5).forEach(i -> { - if (names[i] == null) { + if (names[i] == null || names[i].isEmpty()) { if (format.contains("%s")) { names[i] = switch (i) { case 1 -> format.formatted(tzdbSubstLetters.get(rule + NBSP + STD)); @@ -1531,6 +1534,21 @@ private static void fillTZDBShortNames(String tzid, String[] names) { } } + private static boolean isDefaultZone(String meta, String tzid) { + String zone001 = handlerMetaZones.zidMap().get(meta); + var tzLink = getTZDBLink(tzid); + return canonicalTZMap.getOrDefault(tzid, tzid).equals(zone001) || + tzLink != null && canonicalTZMap.getOrDefault(tzLink, tzLink).equals(zone001); + } + + private static String getTZDBLink(String tzid) { + String tzLink = null; + for (var k = tzid; tzdbLinks.containsKey(k);) { + k = tzLink = tzdbLinks.get(k); + } + return tzLink; + } + /* * Convert TZDB offsets to JDK's offsets, eg, "-08" to "GMT-08:00". * If it cannot recognize the pattern, return the argument as is. diff --git a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java index 4d9b7500d870b..b02f988e7c019 100644 --- a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java +++ b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8181157 8202537 8234347 8236548 8261279 8322647 8174269 8346948 - * 8354548 8381379 + * 8354548 8381379 8382020 * @modules jdk.localedata * @summary Checks CLDR time zone names are generated correctly at * either build or runtime @@ -62,164 +62,218 @@ private static Object[][] sampleTZs() { // no "metazone" zones (some of them were assigned metazones // over time, thus they are not "generated" per se - {"Asia/Srednekolymsk", Locale.US, "Magadan Standard Time", - "GMT+11:00", - "Magadan Summer Time", - "GMT+12:00", - "Magadan Time", - "GMT+11:00"}, - {"Asia/Srednekolymsk", Locale.FRANCE, "heure normale de Magadan", - "UTC+11:00", - "heure d’été de Magadan", - "UTC+12:00", - "heure de Magadan", - "UTC+11:00"}, - {"America/Punta_Arenas", Locale.US, "Punta Arenas Standard Time", - "GMT-03:00", - "Punta Arenas Daylight Time", - "GMT-02:00", - "Punta Arenas Time", - "GMT-03:00"}, - {"America/Punta_Arenas", Locale.FRANCE, "Punta Arenas (heure standard)", - "UTC−03:00", - "Punta Arenas (heure d’été)", - "UTC−02:00", - "heure : Punta Arenas", - "UTC−03:00"}, - {"Asia/Famagusta", Locale.US, "Eastern European Standard Time", - "EET", - "Eastern European Summer Time", - "EEST", - "Eastern European Time", - "EET"}, - {"Asia/Famagusta", Locale.FRANCE, "heure normale d’Europe de l’Est", - "EET", - "heure d’été d’Europe de l’Est", - "EEST", - "heure d’Europe de l’Est", - "EET"}, - {"Europe/Astrakhan", Locale.US, "Samara Standard Time", - "GMT+04:00", - "Samara Summer Time", - "GMT+05:00", - "Samara Time", - "GMT+04:00"}, - {"Europe/Astrakhan", Locale.FRANCE, "heure normale de Samara", - "UTC+04:00", - "heure d’été de Samara", - "UTC+05:00", - "heure de Samara", - "UTC+04:00"}, - {"Europe/Saratov", Locale.US, "Samara Standard Time", - "GMT+04:00", - "Samara Summer Time", - "GMT+05:00", - "Samara Time", - "GMT+04:00"}, - {"Europe/Saratov", Locale.FRANCE, "heure normale de Samara", - "UTC+04:00", - "heure d’été de Samara", - "UTC+05:00", - "heure de Samara", - "UTC+04:00"}, - {"Europe/Ulyanovsk", Locale.US, "Samara Standard Time", - "GMT+04:00", - "Samara Summer Time", - "GMT+05:00", - "Samara Time", - "GMT+04:00"}, - {"Europe/Ulyanovsk", Locale.FRANCE, "heure normale de Samara", - "UTC+04:00", - "heure d’été de Samara", - "UTC+05:00", - "heure de Samara", - "UTC+04:00"}, - {"Pacific/Bougainville", Locale.US, "Bougainville Standard Time", - "GMT+11:00", - "Bougainville Daylight Time", - "GMT+11:00", - "Bougainville Time", - "GMT+11:00"}, - {"Pacific/Bougainville", Locale.FRANCE, "Bougainville (heure standard)", - "UTC+11:00", - "Bougainville (heure d’été)", - "UTC+11:00", - "heure : Bougainville", - "UTC+11:00"}, - {"Europe/Istanbul", Locale.US, "Türkiye Standard Time", - "GMT+03:00", - "Türkiye Summer Time", - "GMT+04:00", - "Türkiye Time", - "GMT+03:00"}, - {"Europe/Istanbul", Locale.FRANCE, "heure normale de Turquie", - "UTC+03:00", - "heure avancée de Turquie", - "UTC+04:00", - "heure de Turquie", - "UTC+03:00"}, - {"Asia/Istanbul", Locale.US, "Türkiye Standard Time", - "GMT+03:00", - "Türkiye Summer Time", - "GMT+04:00", - "Türkiye Time", - "GMT+03:00"}, - {"Asia/Istanbul", Locale.FRANCE, "heure normale de Turquie", - "UTC+03:00", - "heure avancée de Turquie", - "UTC+04:00", - "heure de Turquie", - "UTC+03:00"}, - {"Turkey", Locale.US, "Türkiye Standard Time", - "GMT+03:00", - "Türkiye Summer Time", - "GMT+04:00", - "Türkiye Time", - "GMT+03:00"}, - {"Turkey", Locale.FRANCE, "heure normale de Turquie", - "UTC+03:00", - "heure avancée de Turquie", - "UTC+04:00", - "heure de Turquie", - "UTC+03:00"}, + {"Asia/Srednekolymsk", Locale.US, + "Magadan Standard Time", + "GMT+11:00", + "Magadan Summer Time", + "GMT+12:00", + "Magadan Time", + "GMT+11:00"}, + {"Asia/Srednekolymsk", Locale.FRANCE, + "heure normale de Magadan", + "UTC+11:00", + "heure d’été de Magadan", + "UTC+12:00", + "heure de Magadan", + "UTC+11:00"}, + {"America/Punta_Arenas", Locale.US, + "Punta Arenas Standard Time", + "GMT-03:00", + "Punta Arenas Daylight Time", + "GMT-02:00", + "Punta Arenas Time", + "GMT-03:00"}, + {"America/Punta_Arenas", Locale.FRANCE, + "Punta Arenas (heure standard)", + "UTC−03:00", + "Punta Arenas (heure d’été)", + "UTC−02:00", + "heure : Punta Arenas", + "UTC−03:00"}, + {"Asia/Famagusta", Locale.US, + "Eastern European Standard Time", + "EET", + "Eastern European Summer Time", + "EEST", + "Eastern European Time", + "EET"}, + {"Asia/Famagusta", Locale.FRANCE, + "heure normale d’Europe de l’Est", + "EET", + "heure d’été d’Europe de l’Est", + "EEST", + "heure d’Europe de l’Est", + "EET"}, + {"Europe/Astrakhan", Locale.US, + "Samara Standard Time", + "GMT+04:00", + "Samara Summer Time", + "GMT+05:00", + "Samara Time", + "GMT+04:00"}, + {"Europe/Astrakhan", Locale.FRANCE, + "heure normale de Samara", + "UTC+04:00", + "heure d’été de Samara", + "UTC+05:00", + "heure de Samara", + "UTC+04:00"}, + {"Europe/Saratov", Locale.US, + "Samara Standard Time", + "GMT+04:00", + "Samara Summer Time", + "GMT+05:00", + "Samara Time", + "GMT+04:00"}, + {"Europe/Saratov", Locale.FRANCE, + "heure normale de Samara", + "UTC+04:00", + "heure d’été de Samara", + "UTC+05:00", + "heure de Samara", + "UTC+04:00"}, + {"Europe/Ulyanovsk", Locale.US, + "Samara Standard Time", + "GMT+04:00", + "Samara Summer Time", + "GMT+05:00", + "Samara Time", + "GMT+04:00"}, + {"Europe/Ulyanovsk", Locale.FRANCE, + "heure normale de Samara", + "UTC+04:00", + "heure d’été de Samara", + "UTC+05:00", + "heure de Samara", + "UTC+04:00"}, + {"Pacific/Bougainville", Locale.US, + "Bougainville Standard Time", + "GMT+11:00", + "Bougainville Daylight Time", + "GMT+11:00", + "Bougainville Time", + "GMT+11:00"}, + {"Pacific/Bougainville", Locale.FRANCE, + "Bougainville (heure standard)", + "UTC+11:00", + "Bougainville (heure d’été)", + "UTC+11:00", + "heure : Bougainville", + "UTC+11:00"}, + {"Europe/Istanbul", Locale.US, + "Türkiye Standard Time", + "GMT+03:00", + "Türkiye Summer Time", + "GMT+04:00", + "Türkiye Time", + "GMT+03:00"}, + {"Europe/Istanbul", Locale.FRANCE, + "heure normale de Turquie", + "UTC+03:00", + "heure avancée de Turquie", + "UTC+04:00", + "heure de Turquie", + "UTC+03:00"}, + {"Asia/Istanbul", Locale.US, + "Türkiye Standard Time", + "GMT+03:00", + "Türkiye Summer Time", + "GMT+04:00", + "Türkiye Time", + "GMT+03:00"}, + {"Asia/Istanbul", Locale.FRANCE, + "heure normale de Turquie", + "UTC+03:00", + "heure avancée de Turquie", + "UTC+04:00", + "heure de Turquie", + "UTC+03:00"}, + {"Turkey", Locale.US, + "Türkiye Standard Time", + "GMT+03:00", + "Türkiye Summer Time", + "GMT+04:00", + "Türkiye Time", + "GMT+03:00"}, + {"Turkey", Locale.FRANCE, + "heure normale de Turquie", + "UTC+03:00", + "heure avancée de Turquie", + "UTC+04:00", + "heure de Turquie", + "UTC+03:00"}, // Short names derived from TZDB at build time - {"Europe/Lisbon", Locale.US, "Western European Standard Time", - "WET", - "Western European Summer Time", - "WEST", - "Western European Time", - "WET"}, - {"Atlantic/Azores", Locale.US, "Azores Standard Time", - "GMT-01:00", - "Azores Summer Time", - "GMT", - "Azores Time", - "GMT-01:00"}, - {"Australia/Perth", Locale.US, "Australian Western Standard Time", - "AWST", - "Australian Western Daylight Time", - "AWDT", - "Australian Western Time", - "AWT"}, - {"Africa/Harare", Locale.US, "Central Africa Time", - "CAT", - "Harare Daylight Time", - "CAT", - "Harare Time", - "CAT"}, - {"Europe/Dublin", Locale.US, "Greenwich Mean Time", - "GMT", - "Irish Standard Time", - "IST", - "Dublin Time", - "GMT"}, - {"Pacific/Gambier", Locale.US, "Gambier Time", - "GMT-09:00", - "Gambier Daylight Time", - "GMT-09:00", - "Gambier Time", - "GMT-09:00"}, + {"Europe/Lisbon", Locale.US, + "Western European Standard Time", + "WET", + "Western European Summer Time", + "WEST", + "Western European Time", + "WET"}, + {"Atlantic/Azores", Locale.US, + "Azores Standard Time", + "GMT-01:00", + "Azores Summer Time", + "GMT", + "Azores Time", + "GMT-01:00"}, + {"Australia/Perth", Locale.US, + "Australian Western Standard Time", + "AWST", + "Australian Western Daylight Time", + "AWDT", + "Australian Western Time", + "AWT"}, + {"Africa/Harare", Locale.US, + "Central Africa Time", + "CAT", + "Harare Daylight Time", + "CAT", + "Harare Time", + "CAT"}, + {"Europe/Dublin", Locale.US, + "Greenwich Mean Time", + "GMT", + "Irish Standard Time", + "IST", + "Dublin Time", + "GMT"}, + {"Pacific/Gambier", Locale.US, + "Gambier Time", + "GMT-09:00", + "Gambier Daylight Time", + "GMT-09:00", + "Gambier Time", + "GMT-09:00"}, + {"America/New_York", Locale.US, + "Eastern Standard Time", + "EST", + "Eastern Daylight Time", + "EDT", + "Eastern Time", + "ET"}, + {"America/New_York", Locale.GERMAN, + "Nordamerikanische Ostküsten-Normalzeit", + "EST", + "Nordamerikanische Ostküsten-Sommerzeit", + "EDT", + "Nordamerikanische Ostküstenzeit", + "ET"}, + {"America/New_York", Locale.JAPANESE, + "米国東部標準時", + "EST", + "米国東部夏時間", + "EDT", + "米国東部時間", + "ET"}, + {"America/New_York", Locale.of("ru"), + "Восточная Америка, стандартное время", + "EST", + "Восточная Америка, летнее время", + "EDT", + "Восточная Америка", + "ET"}, }; }