JDK-8285838 : DST not applying properly with zone id offset set with TZ env variable
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 18
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2022-04-28
  • Updated: 2022-11-21
  • Resolved: 2022-06-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20 b02Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
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
Comments
Fix failed with the CI. The test should account for the case "GMT-22" from the OS.
14-06-2022

Changeset: 9b6d0a7e Author: Gaurav Chaudhari <deigue@hotmail.com> Committer: Naoto Sato <naoto@openjdk.org> Date: 2022-06-13 20:01:57 +0000 URL: https://git.openjdk.org/jdk/commit/9b6d0a7e94fd18d302c559bec6f785d71a919a88
13-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8661 Date: 2022-05-11 18:00:31 +0000
17-05-2022