Skip to content

Commit 2a0b143

Browse files
committed
8347841: Test fixes that use deprecated time zone IDs
Backport-of: 50537aefc736db43e4b08133dcd181ba69f10e8d
1 parent 45bbc37 commit 2a0b143

27 files changed

+179
-146
lines changed

test/jdk/java/io/File/TimeZoneLastModified.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,15 +23,14 @@
2323

2424
/*
2525
* @test
26-
* @bug 6212869
26+
* @bug 6212869 8347841
2727
* @summary Determine if lastModified() works after TimeZone.setDefault()
2828
* @run main/othervm TimeZoneLastModified
2929
*/
3030

3131
import java.io.File;
32-
import java.util.Date;
32+
import java.time.ZoneId;
3333
import java.util.TimeZone;
34-
import java.text.SimpleDateFormat;
3534

3635
public class TimeZoneLastModified {
3736
// Tue, 04 Jun 2002 13:56:50.002 GMT
@@ -40,6 +39,9 @@ public class TimeZoneLastModified {
4039
public static void main(String[] args) throws Throwable {
4140
int failures = test(null);
4241
for (String timeZoneID : TimeZone.getAvailableIDs()) {
42+
if (ZoneId.SHORT_IDS.containsKey(timeZoneID)) {
43+
continue;
44+
}
4345
failures += test(timeZoneID);
4446
}
4547
if (failures != 0) {

test/jdk/java/text/Format/DateFormat/DateFormatRegression.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
3434
* @bug 4029195 4052408 4056591 4059917 4060212 4061287 4065240 4071441 4073003
3535
* 4089106 4100302 4101483 4103340 4103341 4104136 4104522 4106807 4108407
3636
* 4134203 4138203 4148168 4151631 4151706 4153860 4162071 4182066 4209272 4210209
37-
* 4213086 4250359 4253490 4266432 4406615 4413980 8008577 8305853
37+
* 4213086 4250359 4253490 4266432 4406615 4413980 8008577 8305853 8347841
3838
* @library /java/text/testlib
3939
* @run junit/othervm -Djava.locale.providers=COMPAT,SPI DateFormatRegression
4040
*/
@@ -274,7 +274,7 @@ public void Test4065240() {
274274
try {
275275
Locale curLocale = new Locale("de","DE");
276276
Locale.setDefault(curLocale);
277-
TimeZone.setDefault(TimeZone.getTimeZone("EST"));
277+
TimeZone.setDefault(TimeZone.getTimeZone("America/Panama"));
278278
curDate = new Date(98, 0, 1);
279279
shortdate = DateFormat.getDateInstance(DateFormat.SHORT);
280280
fulldate = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG
@@ -453,7 +453,7 @@ public void Test4413980() {
453453
TimeZone savedTimeZone = TimeZone.getDefault();
454454
try {
455455
boolean pass = true;
456-
String[] IDs = new String[] {"Undefined", "PST", "US/Pacific",
456+
String[] IDs = new String[] {"Undefined", "America/Los_Angeles", "US/Pacific",
457457
"GMT+3:00", "GMT-01:30"};
458458
for (int i = 0; i < IDs.length; i++) {
459459
TimeZone tz = TimeZone.getTimeZone(IDs[i]);
@@ -543,7 +543,7 @@ public void Test4103340() {
543543
public void Test4103341() {
544544
TimeZone saveZone =TimeZone.getDefault();
545545
try {
546-
TimeZone.setDefault(TimeZone.getTimeZone("CST"));
546+
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago"));
547547
SimpleDateFormat simple = new SimpleDateFormat("MM/dd/yyyy HH:mm");
548548
if (!simple.getTimeZone().equals(TimeZone.getDefault()))
549549
fail("Fail: SimpleDateFormat not using default zone");
@@ -794,7 +794,7 @@ public void Test4406615() {
794794
Locale savedLocale = Locale.getDefault();
795795
TimeZone savedTimeZone = TimeZone.getDefault();
796796
Locale.setDefault(Locale.US);
797-
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
797+
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
798798

799799
Date d1, d2;
800800
String dt = "Mon, 1 Jan 2001 00:00:00";
@@ -1096,7 +1096,7 @@ public void Test4261506() {
10961096

10971097
// XXX: Test assumes "PST" is not TimeZoneNames_ja. Need to
10981098
// pick up another time zone when L10N is done to that file.
1099-
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
1099+
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
11001100
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
11011101
@SuppressWarnings("deprecation")
11021102
String result = fmt.format(new Date(1999 - 1900, 0, 1));

test/jdk/java/text/Format/DateFormat/DateFormatTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,16 @@
2424
/**
2525
* @test
2626
* @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571
27-
* 8190748 8216969
27+
* 8190748 8216969 8347841
2828
* @summary test DateFormat and SimpleDateFormat.
2929
* @modules jdk.localedata
3030
* @run junit/othervm -Djava.locale.providers=COMPAT,SPI DateFormatTest
3131
*/
3232

33-
import java.util.*;
33+
import java.time.ZoneId;
3434
import java.text.*;
35+
import java.util.*;
36+
import java.util.function.Predicate;
3537
import static java.util.GregorianCalendar.*;
3638

3739
import org.junit.jupiter.api.Test;
@@ -89,7 +91,9 @@ public void TestWallyWedel()
8991
/*
9092
* A String array for the time zone ids.
9193
*/
92-
String[] ids = TimeZone.getAvailableIDs();
94+
String[] ids = Arrays.stream(TimeZone.getAvailableIDs())
95+
.filter(Predicate.not(ZoneId.SHORT_IDS::containsKey))
96+
.toArray(String[]::new);
9397
/*
9498
* How many ids do we have?
9599
*/
@@ -179,7 +183,7 @@ public void TestTwoDigitYearDSTParse()
179183
//logln(fmt.format(date)); // This shows what the current locale format is
180184
//logln(((SimpleDateFormat)fmt).toPattern());
181185
TimeZone save = TimeZone.getDefault();
182-
TimeZone PST = TimeZone.getTimeZone("PST");
186+
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
183187
String s = "03-Apr-04 2:20:47 o'clock AM PST";
184188
int hour = 2;
185189
try {
@@ -271,7 +275,7 @@ public void TestFieldPosition()
271275
"0034", "0012", "0513", "Pacific Daylight Time",
272276
};
273277
Date someDate = new Date(871508052513L);
274-
TimeZone PST = TimeZone.getTimeZone("PST");
278+
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
275279
for (int j = 0, exp = 0; j < dateFormats.length; ++j) {
276280
DateFormat df = dateFormats[j];
277281
if (!(df instanceof SimpleDateFormat)) {

test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,13 @@
2323

2424
/**
2525
* @test
26-
* @bug 8218948
26+
* @bug 8218948 8347841
2727
* @summary TCK tests that check the time zone names between DFS.getZoneStrings()
2828
* and SDF.format("z*")
2929
* @run main SDFTCKZoneNamesTest
3030
*/
3131
import java.text.*;
32+
import java.time.ZoneId;
3233
import java.util.Calendar;
3334
import java.util.Date;
3435
import java.util.List;
@@ -325,6 +326,9 @@ public void SimpleDateFormat0062() {
325326
SimpleDateFormat sdf = new SimpleDateFormat();
326327
Date date = new Date(1234567890);
327328
for (String[] tz : sdf.getDateFormatSymbols().getZoneStrings()) {
329+
if (ZoneId.SHORT_IDS.containsKey(tz[0])) {
330+
continue;
331+
}
328332
sdf.setTimeZone(TimeZone.getTimeZone(tz[0]));
329333
for (int i = 0; i < patterns.length && passed; i++) {
330334
StringBuffer result = new StringBuffer("qwerty");

test/jdk/java/text/Format/DateFormat/bug4358730.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
3131

3232
/**
3333
* @test
34-
* @bug 4358730
34+
* @bug 4358730 8347841
3535
* @summary test that confirms Zero-Padding on year.
3636
* @run junit bug4358730
3737
*/
@@ -56,7 +56,7 @@ public void Test4358730() {
5656
Locale saveLocale = Locale.getDefault();
5757

5858
try {
59-
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
59+
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
6060
Locale.setDefault(new Locale("en", "US"));
6161
SimpleDateFormat sdf = new SimpleDateFormat();
6262

test/jdk/java/util/Calendar/CalendarRegression.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
3030
* 4174361 4177484 4197699 4209071 4288792 4328747 4413980 4546637 4623997
3131
* 4685354 4655637 4683492 4080631 4080631 4167995 4340146 4639407
3232
* 4652815 4652830 4740554 4936355 4738710 4633646 4846659 4822110 4960642
33-
* 4973919 4980088 4965624 5013094 5006864 8152077
33+
* 4973919 4980088 4965624 5013094 5006864 8152077 8347841
3434
* @library /java/text/testlib
3535
* @run junit CalendarRegression
3636
*/
@@ -42,6 +42,8 @@
4242
import java.text.DateFormat;
4343
import java.text.NumberFormat;
4444
import java.text.SimpleDateFormat;
45+
import java.time.ZoneId;
46+
import java.util.Arrays;
4547
import java.util.Calendar;
4648
import java.util.Date;
4749
import java.util.GregorianCalendar;
@@ -50,6 +52,7 @@
5052
import java.util.Map;
5153
import java.util.SimpleTimeZone;
5254
import java.util.TimeZone;
55+
import java.util.function.Predicate;
5356

5457
import static java.util.Calendar.*;
5558

@@ -75,7 +78,9 @@ public class CalendarRegression {
7578
public void Test4031502() {
7679
// This bug actually occurs on Windows NT as well, and doesn't
7780
// require the host zone to be set; it can be set in Java.
78-
String[] ids = TimeZone.getAvailableIDs();
81+
String[] ids = Arrays.stream(TimeZone.getAvailableIDs())
82+
.filter(Predicate.not(ZoneId.SHORT_IDS::containsKey))
83+
.toArray(String[]::new);
7984
boolean bad = false;
8085
for (int i = 0; i < ids.length; ++i) {
8186
TimeZone zone = TimeZone.getTimeZone(ids[i]);
@@ -489,7 +494,7 @@ public void Test4095407() {
489494
@Test
490495
public void Test4096231() {
491496
TimeZone GMT = TimeZone.getTimeZone("GMT");
492-
TimeZone PST = TimeZone.getTimeZone("PST");
497+
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
493498
int sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997;
494499

495500
Calendar cal1 = new GregorianCalendar(PST);
@@ -838,7 +843,7 @@ public void Test4114578() {
838843
TimeZone saveZone = TimeZone.getDefault();
839844
boolean fail = false;
840845
try {
841-
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
846+
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
842847
Calendar cal = Calendar.getInstance();
843848
long onset = new Date(98, APRIL, 5, 1, 0).getTime() + ONE_HOUR;
844849
long cease = new Date(98, OCTOBER, 25, 0, 0).getTime() + 2 * ONE_HOUR;
@@ -1163,8 +1168,8 @@ public void Test4147269() {
11631168
@Test
11641169
public void Test4149677() {
11651170
TimeZone[] zones = {TimeZone.getTimeZone("GMT"),
1166-
TimeZone.getTimeZone("PST"),
1167-
TimeZone.getTimeZone("EAT")};
1171+
TimeZone.getTimeZone("America/Los_Angeles"),
1172+
TimeZone.getTimeZone("Africa/Addis_Ababa")};
11681173
for (int i = 0; i < zones.length; ++i) {
11691174
GregorianCalendar calendar = new GregorianCalendar(zones[i]);
11701175

@@ -1197,7 +1202,7 @@ public void Test4149677() {
11971202
@Test
11981203
public void Test4162587() {
11991204
TimeZone savedTz = TimeZone.getDefault();
1200-
TimeZone tz = TimeZone.getTimeZone("PST");
1205+
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
12011206
TimeZone.setDefault(tz);
12021207
GregorianCalendar cal = new GregorianCalendar(tz);
12031208
Date d;
@@ -1511,8 +1516,8 @@ public void Test4174361() {
15111516
*/
15121517
@Test
15131518
public void Test4177484() {
1514-
TimeZone PST = TimeZone.getTimeZone("PST");
1515-
TimeZone EST = TimeZone.getTimeZone("EST");
1519+
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
1520+
TimeZone EST = TimeZone.getTimeZone("America/Panama");
15161521

15171522
Calendar cal = Calendar.getInstance(PST, Locale.US);
15181523
cal.clear();
@@ -1770,7 +1775,7 @@ public void Test4413980() {
17701775
TimeZone savedTimeZone = TimeZone.getDefault();
17711776
try {
17721777
boolean pass = true;
1773-
String[] IDs = new String[]{"Undefined", "PST", "US/Pacific",
1778+
String[] IDs = new String[]{"Undefined", "America/Los_Angeles", "US/Pacific",
17741779
"GMT+3:00", "GMT-01:30"};
17751780
for (int i = 0; i < IDs.length; i++) {
17761781
TimeZone tz = TimeZone.getTimeZone(IDs[i]);

test/jdk/java/util/Calendar/JavatimeTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
*@test
26-
*@bug 8007520 8008254
26+
*@bug 8007520 8008254 8347841
2727
*@summary Test those bridge methods to/from java.time date/time classes
2828
* @key randomness
2929
*/
@@ -107,23 +107,22 @@ public static void main(String[] args) throws Throwable {
107107

108108
///////////// java.util.TimeZone /////////////////////////
109109
for (String zidStr : TimeZone.getAvailableIDs()) {
110-
// TBD: tzdt intergration
110+
if (ZoneId.SHORT_IDS.containsKey(zidStr)) {
111+
continue;
112+
}
113+
// TBD: tzdt integration
111114
if (zidStr.startsWith("SystemV")
112115
|| zidStr.contains("Riyadh8")
113-
|| zidStr.equals("US/Pacific-New")
114-
|| zidStr.equals("EST")
115-
|| zidStr.equals("HST")
116-
|| zidStr.equals("MST")) {
116+
|| zidStr.equals("US/Pacific-New")) {
117117
continue;
118118
}
119-
ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
119+
ZoneId zid = ZoneId.of(zidStr);
120120
if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) {
121121
throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr);
122122
}
123123
TimeZone tz = TimeZone.getTimeZone(zidStr);
124124
// no round-trip for alias and "GMT"
125125
if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId()))
126-
&& !ZoneId.SHORT_IDS.containsKey(zidStr)
127126
&& !zidStr.startsWith("GMT")) {
128127
throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
129128
}

test/jdk/java/util/Calendar/bug4316678.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 4316678
26+
* @bug 4316678 8347841
2727
* @summary test that Calendar's Serialization works correctly.
2828
* @run junit bug4316678
2929
*/
@@ -53,7 +53,7 @@ public class bug4316678 {
5353
// Set custom JVM default TimeZone
5454
@BeforeAll
5555
static void initAll() {
56-
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
56+
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
5757
}
5858

5959
// Restore JVM default Locale and TimeZone

0 commit comments

Comments
 (0)