JSR 310 :: System.currentTimeMillis() vs Instant.toEpochMilli() :: TimeZone
问题 Could you please shed some light on how to obtain correct epoch time in milliseconds for a default system timezone and given timezone. Given 1. TimeZone: GMT+3 2. The following code snippet: import java.time.*; public class Main { public static void main(String[] args) { System.out.println(LocalDateTime .now() .atZone(ZoneOffset.UTC) .toInstant() .toEpochMilli() ); System.out.println(LocalDateTime .now() .atZone(ZoneOffset.of("+3")) .toInstant() .toEpochMilli() ); System.out.println(System