-
Bug
-
Resolution: Fixed
-
P4
-
18
-
None
-
b02
-
Fix failed
On behalf of Gaurav Chaudhari:
When a match cannot be made directly against a recognized region/timezone from the tzdb.dat, TimeZone.getSystemGMTOffsetID() is invoked to find the GMT based offset to calculate the offset and find the corresponding time.
The native code reached in TimeZone_md.c has a bug for platforms that are not MacOS, where daylight savings is not respected.
To reproduce the issue:
TZ="MEZ-1MESZ,M3.5.0,M10.5.0" java -cp . TimeTest
with the following test , TimeTest.java
import java.util.Calendar;
import java.util.TimeZone;
import java.util.Date;
import java.text.SimpleDateFormat;
public class TimeTest {
public static void main(String args[]) {
Date time = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SSS");
System.out.println("Calendar.getInstance().getTime() = "+time);
System.out.println("SimpleDateFormat = "+sdf.format(time));
}
}
Reproducible on Linux on Z (s390x) OpenJDK18 (jdk18+38 Temurin)
TZ="MEZ-1MESZ,M3.5.0,M10.5.0" ~/jdk-18+36/bin/java -cp . TimeTest
Calendar.getInstance().getTime() = Thu Apr 28 15:55:16 GMT+01:00 2022
SimpleDateFormat = 28.04.2022 15:55:16.171
Zone ID can be set according to guidelines below:
https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
When a match cannot be made directly against a recognized region/timezone from the tzdb.dat, TimeZone.getSystemGMTOffsetID() is invoked to find the GMT based offset to calculate the offset and find the corresponding time.
The native code reached in TimeZone_md.c has a bug for platforms that are not MacOS, where daylight savings is not respected.
To reproduce the issue:
TZ="MEZ-1MESZ,M3.5.0,M10.5.0" java -cp . TimeTest
with the following test , TimeTest.java
import java.util.Calendar;
import java.util.TimeZone;
import java.util.Date;
import java.text.SimpleDateFormat;
public class TimeTest {
public static void main(String args[]) {
Date time = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SSS");
System.out.println("Calendar.getInstance().getTime() = "+time);
System.out.println("SimpleDateFormat = "+sdf.format(time));
}
}
Reproducible on Linux on Z (s390x) OpenJDK18 (jdk18+38 Temurin)
TZ="MEZ-1MESZ,M3.5.0,M10.5.0" ~/jdk-18+36/bin/java -cp . TimeTest
Calendar.getInstance().getTime() = Thu Apr 28 15:55:16 GMT+01:00 2022
SimpleDateFormat = 28.04.2022 15:55:16.171
Zone ID can be set according to guidelines below:
https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
- relates to
-
JDK-6992725 SimpleDateFormat.format(Date) is an hour late for MEZ-1MESZ,M3.5.0,M10.5.0
- Closed
-
JDK-8297335 Date and time handling in timezone that supports daylight savings time
- Open
-
JDK-8288369 java/util/TimeZone/CustomTzIDCheckDST.java failed with "RuntimeException: Got unexpected timezone information"
- Closed
-
JDK-8288377 [REDO] DST not applying properly with zone id offset set with TZ env variable
- Closed
(1 links to)