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 ?