I'm trying to get value of the exp datetime in a JWT token.
exp is the expiration time after which JWT must not be accepted.
In JavaScript I get the correct result by
new Date(1661159784*1000)
the correct result is
Mon Aug 22 2022 11:16:24 GMT+0200 (CEST)
Why didn't I get the same in Java?
Java:
System.out.println(new Date(1661159784 * 1000));
result:
Sat Dec 20 13:17:20 CET 1969
The same result setting s UTC time zone:
final ZonedDateTime exp2 = Instant.ofEpochMilli(1661159784 * 1000)
.atZone(ZoneOffset.UTC);
System.out.println(exp2);
result:
1969-12-20T12:17:20.448Z