From d031d51ca9d569dd559c19ba63faa9c970185eb7 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 22 Jul 2026 14:18:48 -0700 Subject: [PATCH 1/2] initial commit --- .../resources/cldr/TimeZoneNamesTest.java | 72 +++++++++++++++---- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java index 60359b8fbd4e0..0fb20c4992e92 100644 --- a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java +++ b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java @@ -26,11 +26,15 @@ * @bug 8181157 8202537 8234347 8236548 8261279 8322647 8174269 8346948 * 8354548 8381379 8382020 8384043 8371842 * @modules jdk.localedata + * java.base/sun.util.calendar * @summary Checks CLDR time zone names are generated correctly at * either build or runtime * @run junit TimeZoneNamesTest */ +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.time.ZoneId; @@ -39,11 +43,15 @@ import java.time.format.TextStyle; import java.util.Arrays; import java.util.Date; +import java.util.HashSet; import java.util.Locale; import java.util.Objects; +import java.util.Set; import java.util.TimeZone; import java.util.stream.Stream; +import sun.util.calendar.ZoneInfoFile; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -52,12 +60,31 @@ import static org.junit.jupiter.api.Assertions.assertFalse; public class TimeZoneNamesTest { + private static Set EXPLICIT_OFFSET_ZONES; + + @BeforeAll + static void findExplictOffsetZones() throws IOException { + EXPLICIT_OFFSET_ZONES = new HashSet<>(); + var lines = Files.readAllLines(Paths.get(System.getProperty("test.root"), + "../../make/data/cldr/common/supplemental/metaZones.xml")); + String zone = null; + for (var line : lines) { + line = line.trim(); + if (line.startsWith("$", ""); + } else if (line.startsWith(" explicitDstOffsets() { return Stream.of( - Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("Europe/Dublin")), "Irish Standard Time"), - Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("Europe/Dublin")), "Greenwich Mean Time"), - Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("Eire")), "Irish Standard Time"), - Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("Eire")), "Greenwich Mean Time"), - Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time"), - Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time") + // CLDR v48 + Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("Europe/Dublin")), "Irish Standard Time", "IST"), + Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("Europe/Dublin")), "Greenwich Mean Time", "GMT"), + Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("Eire")), "Irish Standard Time", "IST"), + Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("Eire")), "Greenwich Mean Time", "GMT"), + // CLDR v48.2 & tz2026b. British Columbia switched to permanent DST + Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time", "PDT"), + Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time", "PDT"), + // CLDR v49 & tz2026c. Alberta switched to permanent DST + Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("America/Edmonton")), "Mountain Daylight Time", "MDT"), + checkVer("2026c", 49, 0) ? + Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Edmonton")), "Mountain Daylight Time", "MDT") : + Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Edmonton")), "Mountain Standard Time", "MST") ); } + // Explicit dstOffset is enabled in two steps. First step is the IANA TZ Database rule update, and the second + // step is CLDR metazone update with explicit offsets. This method checks the required tzdb & CLDR versions + private static boolean checkVer(String requiredTZVer, int requiredCLDRMajor, int requiredCLDRMMinor) { + return ZoneInfoFile.getVersion().compareTo(requiredTZVer) >= 0; + } + @ParameterizedTest @MethodSource("sampleTZs") public void test_tzNames(String tzid, Locale locale, String lstd, String sstd, String ldst, String sdst, String lgen, String sgen) { @@ -340,18 +380,22 @@ public void test_getZoneStrings() { "getZoneStrings() returned array containing non-empty string element(s)"); } - // Explicit metazone dst offset test. As of CLDR v48, only Europe/Dublin utilizes - // this attribute, but will be used for America/Vancouver once CLDR adopts the - // explicit offset for that zone, which warrants the test data modification. + // Explicit metazone dst offset test. @ParameterizedTest @MethodSource("explicitDstOffsets") - public void test_ExplicitMetazoneOffsets(ZonedDateTime zdt, String expected) { + public void test_ExplicitMetazoneOffsets(ZonedDateTime zdt, String expectedLong, String expectedShort) { // java.time - assertEquals(expected, DateTimeFormatter.ofPattern("zzzz").format(zdt)); + assertEquals(expectedLong, DateTimeFormatter.ofPattern("zzzz").format(zdt)); + assertEquals(expectedShort, DateTimeFormatter.ofPattern("z").format(zdt)); // java.text/util + var date = Date.from(zdt.toInstant()); + var tz = TimeZone.getTimeZone(zdt.getZone()); var sdf = new SimpleDateFormat("zzzz"); - sdf.setTimeZone(TimeZone.getTimeZone(zdt.getZone())); - assertEquals(expected, sdf.format(Date.from(zdt.toInstant()))); + sdf.setTimeZone(tz); + assertEquals(expectedLong, sdf.format(date)); + sdf = new SimpleDateFormat("z"); + sdf.setTimeZone(tz); + assertEquals(expectedShort, sdf.format(date)); } } From de43663340ea07a8fc3b88218191a16a7ba8e84e Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Mon, 27 Jul 2026 15:18:36 -0700 Subject: [PATCH 2/2] Removed auto-detect code --- .../resources/cldr/TimeZoneNamesTest.java | 51 +++---------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java index 0fb20c4992e92..f9610436bc9e5 100644 --- a/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java +++ b/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java @@ -26,15 +26,11 @@ * @bug 8181157 8202537 8234347 8236548 8261279 8322647 8174269 8346948 * 8354548 8381379 8382020 8384043 8371842 * @modules jdk.localedata - * java.base/sun.util.calendar * @summary Checks CLDR time zone names are generated correctly at * either build or runtime * @run junit TimeZoneNamesTest */ -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.time.ZoneId; @@ -43,15 +39,11 @@ import java.time.format.TextStyle; import java.util.Arrays; import java.util.Date; -import java.util.HashSet; import java.util.Locale; import java.util.Objects; -import java.util.Set; import java.util.TimeZone; import java.util.stream.Stream; -import sun.util.calendar.ZoneInfoFile; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -60,32 +52,13 @@ import static org.junit.jupiter.api.Assertions.assertFalse; public class TimeZoneNamesTest { - private static Set EXPLICIT_OFFSET_ZONES; - - @BeforeAll - static void findExplictOffsetZones() throws IOException { - EXPLICIT_OFFSET_ZONES = new HashSet<>(); - var lines = Files.readAllLines(Paths.get(System.getProperty("test.root"), - "../../make/data/cldr/common/supplemental/metaZones.xml")); - String zone = null; - for (var line : lines) { - line = line.trim(); - if (line.startsWith("$", ""); - } else if (line.startsWith(" explicitDstOffsets() { Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("Europe/Dublin")), "Greenwich Mean Time", "GMT"), Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("Eire")), "Irish Standard Time", "IST"), Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("Eire")), "Greenwich Mean Time", "GMT"), - // CLDR v48.2 & tz2026b. British Columbia switched to permanent DST + // CLDR v48.2 & tz2026b. America/Vancouver switched to permanent DST Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time", "PDT"), - Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time", "PDT"), - // CLDR v49 & tz2026c. Alberta switched to permanent DST - Arguments.of(ZonedDateTime.of(2026, 4, 5, 0, 0, 0, 0, ZoneId.of("America/Edmonton")), "Mountain Daylight Time", "MDT"), - checkVer("2026c", 49, 0) ? - Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Edmonton")), "Mountain Daylight Time", "MDT") : - Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Edmonton")), "Mountain Standard Time", "MST") + Arguments.of(ZonedDateTime.of(2026, 12, 5, 0, 0, 0, 0, ZoneId.of("America/Vancouver")), "Pacific Daylight Time", "PDT") ); } - // Explicit dstOffset is enabled in two steps. First step is the IANA TZ Database rule update, and the second - // step is CLDR metazone update with explicit offsets. This method checks the required tzdb & CLDR versions - private static boolean checkVer(String requiredTZVer, int requiredCLDRMajor, int requiredCLDRMMinor) { - return ZoneInfoFile.getVersion().compareTo(requiredTZVer) >= 0; - } - @ParameterizedTest @MethodSource("sampleTZs") public void test_tzNames(String tzid, Locale locale, String lstd, String sstd, String ldst, String sdst, String lgen, String sgen) { @@ -380,7 +342,10 @@ public void test_getZoneStrings() { "getZoneStrings() returned array containing non-empty string element(s)"); } - // Explicit metazone dst offset test. + // Explicit metazone DST offset test. This attribute is used for Europe/Dublin + // to support the negative DST. Also, it is used to support permanent DST names, + // such as with America/Vancouver. For the latter case, both CLDR data and corresponding + // updated TZDB data are required (e.g., tz2026b for America/Vancouver). @ParameterizedTest @MethodSource("explicitDstOffsets") public void test_ExplicitMetazoneOffsets(ZonedDateTime zdt, String expectedLong, String expectedShort) {