Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions test/jdk/java/io/File/TimeZoneLastModified.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,15 +23,14 @@

/*
* @test
* @bug 6212869
* @bug 6212869 8347841
* @summary Determine if lastModified() works after TimeZone.setDefault()
* @run main/othervm TimeZoneLastModified
*/

import java.io.File;
import java.util.Date;
import java.time.ZoneId;
import java.util.TimeZone;
import java.text.SimpleDateFormat;

public class TimeZoneLastModified {
// Tue, 04 Jun 2002 13:56:50.002 GMT
Expand All @@ -40,6 +39,9 @@ public class TimeZoneLastModified {
public static void main(String[] args) throws Throwable {
int failures = test(null);
for (String timeZoneID : TimeZone.getAvailableIDs()) {
if (ZoneId.SHORT_IDS.containsKey(timeZoneID)) {
continue;
}
failures += test(timeZoneID);
}
if (failures != 0) {
Expand Down
14 changes: 7 additions & 7 deletions test/jdk/java/text/Format/DateFormat/DateFormatRegression.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,7 @@
* @bug 4029195 4052408 4056591 4059917 4060212 4061287 4065240 4071441 4073003
* 4089106 4100302 4101483 4103340 4103341 4104136 4104522 4106807 4108407
* 4134203 4138203 4148168 4151631 4151706 4153860 4162071 4182066 4209272 4210209
* 4213086 4250359 4253490 4266432 4406615 4413980 8008577 8305853
* 4213086 4250359 4253490 4266432 4406615 4413980 8008577 8305853 8347841
* @library /java/text/testlib
* @run junit/othervm -Djava.locale.providers=COMPAT,SPI DateFormatRegression
*/
Expand Down Expand Up @@ -274,7 +274,7 @@ public void Test4065240() {
try {
Locale curLocale = new Locale("de","DE");
Locale.setDefault(curLocale);
TimeZone.setDefault(TimeZone.getTimeZone("EST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Panama"));
curDate = new Date(98, 0, 1);
shortdate = DateFormat.getDateInstance(DateFormat.SHORT);
fulldate = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG
Expand Down Expand Up @@ -453,7 +453,7 @@ public void Test4413980() {
TimeZone savedTimeZone = TimeZone.getDefault();
try {
boolean pass = true;
String[] IDs = new String[] {"Undefined", "PST", "US/Pacific",
String[] IDs = new String[] {"Undefined", "America/Los_Angeles", "US/Pacific",
"GMT+3:00", "GMT-01:30"};
for (int i = 0; i < IDs.length; i++) {
TimeZone tz = TimeZone.getTimeZone(IDs[i]);
Expand Down Expand Up @@ -543,7 +543,7 @@ public void Test4103340() {
public void Test4103341() {
TimeZone saveZone =TimeZone.getDefault();
try {
TimeZone.setDefault(TimeZone.getTimeZone("CST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago"));
SimpleDateFormat simple = new SimpleDateFormat("MM/dd/yyyy HH:mm");
if (!simple.getTimeZone().equals(TimeZone.getDefault()))
fail("Fail: SimpleDateFormat not using default zone");
Expand Down Expand Up @@ -794,7 +794,7 @@ public void Test4406615() {
Locale savedLocale = Locale.getDefault();
TimeZone savedTimeZone = TimeZone.getDefault();
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));

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

// XXX: Test assumes "PST" is not TimeZoneNames_ja. Need to
// pick up another time zone when L10N is done to that file.
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
@SuppressWarnings("deprecation")
String result = fmt.format(new Date(1999 - 1900, 0, 1));
Expand Down
16 changes: 10 additions & 6 deletions test/jdk/java/text/Format/DateFormat/DateFormatTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,14 +24,16 @@
/**
* @test
* @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571
* 8190748 8216969
* 8190748 8216969 8347841
* @summary test DateFormat and SimpleDateFormat.
* @modules jdk.localedata
* @run junit/othervm -Djava.locale.providers=COMPAT,SPI DateFormatTest
*/

import java.util.*;
import java.time.ZoneId;
import java.text.*;
import java.util.*;
import java.util.function.Predicate;
import static java.util.GregorianCalendar.*;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -89,7 +91,9 @@ public void TestWallyWedel()
/*
* A String array for the time zone ids.
*/
String[] ids = TimeZone.getAvailableIDs();
String[] ids = Arrays.stream(TimeZone.getAvailableIDs())
.filter(Predicate.not(ZoneId.SHORT_IDS::containsKey))
.toArray(String[]::new);
/*
* How many ids do we have?
*/
Expand Down Expand Up @@ -179,7 +183,7 @@ public void TestTwoDigitYearDSTParse()
//logln(fmt.format(date)); // This shows what the current locale format is
//logln(((SimpleDateFormat)fmt).toPattern());
TimeZone save = TimeZone.getDefault();
TimeZone PST = TimeZone.getTimeZone("PST");
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
String s = "03-Apr-04 2:20:47 o'clock AM PST";
int hour = 2;
try {
Expand Down Expand Up @@ -271,7 +275,7 @@ public void TestFieldPosition()
"0034", "0012", "0513", "Pacific Daylight Time",
};
Date someDate = new Date(871508052513L);
TimeZone PST = TimeZone.getTimeZone("PST");
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
for (int j = 0, exp = 0; j < dateFormats.length; ++j) {
DateFormat df = dateFormats[j];
if (!(df instanceof SimpleDateFormat)) {
Expand Down
8 changes: 6 additions & 2 deletions test/jdk/java/text/Format/DateFormat/SDFTCKZoneNamesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,12 +23,13 @@

/**
* @test
* @bug 8218948
* @bug 8218948 8347841
* @summary TCK tests that check the time zone names between DFS.getZoneStrings()
* and SDF.format("z*")
* @run main SDFTCKZoneNamesTest
*/
import java.text.*;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -325,6 +326,9 @@ public void SimpleDateFormat0062() {
SimpleDateFormat sdf = new SimpleDateFormat();
Date date = new Date(1234567890);
for (String[] tz : sdf.getDateFormatSymbols().getZoneStrings()) {
if (ZoneId.SHORT_IDS.containsKey(tz[0])) {
continue;
}
sdf.setTimeZone(TimeZone.getTimeZone(tz[0]));
for (int i = 0; i < patterns.length && passed; i++) {
StringBuffer result = new StringBuffer("qwerty");
Expand Down
6 changes: 3 additions & 3 deletions test/jdk/java/text/Format/DateFormat/bug4358730.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,7 +31,7 @@

/**
* @test
* @bug 4358730
* @bug 4358730 8347841
* @summary test that confirms Zero-Padding on year.
* @run junit bug4358730
*/
Expand All @@ -56,7 +56,7 @@ public void Test4358730() {
Locale saveLocale = Locale.getDefault();

try {
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
Locale.setDefault(new Locale("en", "US"));
SimpleDateFormat sdf = new SimpleDateFormat();

Expand Down
27 changes: 16 additions & 11 deletions test/jdk/java/util/Calendar/CalendarRegression.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,7 +30,7 @@
* 4174361 4177484 4197699 4209071 4288792 4328747 4413980 4546637 4623997
* 4685354 4655637 4683492 4080631 4080631 4167995 4340146 4639407
* 4652815 4652830 4740554 4936355 4738710 4633646 4846659 4822110 4960642
* 4973919 4980088 4965624 5013094 5006864 8152077
* 4973919 4980088 4965624 5013094 5006864 8152077 8347841
* @library /java/text/testlib
* @run junit CalendarRegression
*/
Expand All @@ -42,6 +42,8 @@
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
Expand All @@ -50,6 +52,7 @@
import java.util.Map;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import java.util.function.Predicate;

import static java.util.Calendar.*;

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

Calendar cal1 = new GregorianCalendar(PST);
Expand Down Expand Up @@ -838,7 +843,7 @@ public void Test4114578() {
TimeZone saveZone = TimeZone.getDefault();
boolean fail = false;
try {
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
Calendar cal = Calendar.getInstance();
long onset = new Date(98, APRIL, 5, 1, 0).getTime() + ONE_HOUR;
long cease = new Date(98, OCTOBER, 25, 0, 0).getTime() + 2 * ONE_HOUR;
Expand Down Expand Up @@ -1163,8 +1168,8 @@ public void Test4147269() {
@Test
public void Test4149677() {
TimeZone[] zones = {TimeZone.getTimeZone("GMT"),
TimeZone.getTimeZone("PST"),
TimeZone.getTimeZone("EAT")};
TimeZone.getTimeZone("America/Los_Angeles"),
TimeZone.getTimeZone("Africa/Addis_Ababa")};
for (int i = 0; i < zones.length; ++i) {
GregorianCalendar calendar = new GregorianCalendar(zones[i]);

Expand Down Expand Up @@ -1197,7 +1202,7 @@ public void Test4149677() {
@Test
public void Test4162587() {
TimeZone savedTz = TimeZone.getDefault();
TimeZone tz = TimeZone.getTimeZone("PST");
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
TimeZone.setDefault(tz);
GregorianCalendar cal = new GregorianCalendar(tz);
Date d;
Expand Down Expand Up @@ -1511,8 +1516,8 @@ public void Test4174361() {
*/
@Test
public void Test4177484() {
TimeZone PST = TimeZone.getTimeZone("PST");
TimeZone EST = TimeZone.getTimeZone("EST");
TimeZone PST = TimeZone.getTimeZone("America/Los_Angeles");
TimeZone EST = TimeZone.getTimeZone("America/Panama");

Calendar cal = Calendar.getInstance(PST, Locale.US);
cal.clear();
Expand Down Expand Up @@ -1770,7 +1775,7 @@ public void Test4413980() {
TimeZone savedTimeZone = TimeZone.getDefault();
try {
boolean pass = true;
String[] IDs = new String[]{"Undefined", "PST", "US/Pacific",
String[] IDs = new String[]{"Undefined", "America/Los_Angeles", "US/Pacific",
"GMT+3:00", "GMT-01:30"};
for (int i = 0; i < IDs.length; i++) {
TimeZone tz = TimeZone.getTimeZone(IDs[i]);
Expand Down
17 changes: 8 additions & 9 deletions test/jdk/java/util/Calendar/JavatimeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@

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

///////////// java.util.TimeZone /////////////////////////
for (String zidStr : TimeZone.getAvailableIDs()) {
// TBD: tzdt intergration
if (ZoneId.SHORT_IDS.containsKey(zidStr)) {
continue;
}
// TBD: tzdt integration
if (zidStr.startsWith("SystemV")
|| zidStr.contains("Riyadh8")
|| zidStr.equals("US/Pacific-New")
|| zidStr.equals("EST")
|| zidStr.equals("HST")
|| zidStr.equals("MST")) {
|| zidStr.equals("US/Pacific-New")) {
continue;
}
ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
ZoneId zid = ZoneId.of(zidStr);
if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) {
throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr);
}
TimeZone tz = TimeZone.getTimeZone(zidStr);
// no round-trip for alias and "GMT"
if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId()))
&& !ZoneId.SHORT_IDS.containsKey(zidStr)
&& !zidStr.startsWith("GMT")) {
throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
}
Expand Down
6 changes: 3 additions & 3 deletions test/jdk/java/util/Calendar/bug4316678.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 4316678
* @bug 4316678 8347841
* @summary test that Calendar's Serialization works correctly.
* @run junit bug4316678
*/
Expand Down Expand Up @@ -53,7 +53,7 @@ public class bug4316678 {
// Set custom JVM default TimeZone
@BeforeAll
static void initAll() {
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
}

// Restore JVM default Locale and TimeZone
Expand Down
Loading