JDK-8297335 : Date and time handling in timezone that supports daylight savings time
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-11-21
  • Updated: 2022-11-21
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.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
After JDK-8285838/JDK-8288377, I assume Java cannot handle DST.
But I got following result.

Test case:
==============================
$ cat tza.java 
import java.util.*;

public class tza {
  public static void main(String[] args) throws Exception {
    Date date = args.length > 0 ?
      new Date(Long.parseLong(args[0]) * 1000L) : new Date();
    System.out.println(date);
  }
}
==============================

Today is:
Now I'm not in non-DST.
==============================
$ TZ=MEZ-1MESZ,M3.5.0,M10.5.0 date
Mon Nov 21 12:44:08 MEZ 2022
$ TZ=MEZ-1MESZ,M3.5.0,M10.5.0 ~/jdk-20-b24/bin/java tza.java
Mon Nov 21 12:44:14 GMT+01:00 2022
==============================

1651161316 means Unix epoch time for "Thu Apr 28 15:55:16 2022 UTC"
==============================
$ TZ=MEZ-1MESZ,M3.5.0,M10.5.0 ~/jdk-20-b24/bin/java tza.java 1651161316
Thu Apr 28 16:55:16 GMT+01:00 2022
==============================

I created same kind of test program by C.
==============================
$ cat getlocaltime.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int 
main(int argc, char *argv[]) {
  struct tm *local_tm;
  char buf[256];
  time_t t;
  
  if (argc != 2) {
    fprintf(stderr, "Usage: getlocaltime epochtime\n");
    exit(1);
  }
  
  t = atol(argv[1]);
  local_tm = localtime(&t);
  strftime(buf, sizeof(buf), "%a %b %e %H:%M:%S %Y %Z", local_tm);
  fprintf(stderr, "%s\n", buf);
  exit(0);
}
$ TZ=MEZ-1MESZ,M3.5.0,M10.5.0 ./getlocaltime 1651161316
Thu Apr 28 17:55:16 2022 MESZ
==============================

Result:
Now I'm not in non-DST.
Java's test program output is "Thu Apr 28 16:55:16 GMT+01:00 2022"
Native test program output is "Thu Apr 28 17:55:16 2022 MESZ"

Time was not same.
I'd like to confirm it's expected result ?
Comments
Hi Ichiro, I'll reach out to Gaurav and be in touch.
21-11-2022

The original bug was fixed by Gaurav Chaudhari.
21-11-2022