Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ private static Object[][] sampleTZs() {
return new Object[][] {
// tzid, locale, style, expected

// This list is as of CLDR version 48, and should be examined
// on the CLDR data upgrade.
// This list is current as of CLDR 48.2 and should be reviewed
// whenever the CLDR data is upgraded.

// no "metazone" zones (some of them were assigned metazones
// over time, thus they are not "generated" per se
Expand Down Expand Up @@ -300,12 +300,14 @@ private static Object[][] sampleTZs() {

private static Stream<Arguments> 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. 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")
);
}

Expand Down Expand Up @@ -340,18 +342,25 @@ 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. 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 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));
}
}