Java's LocalDateTime.now () says it gets the default timezone, but I tried to figure it out.
Source code
package test;
import java.time.LocalDateTime;
import java.time.ZoneId;
public class Test {
public static void main(String[] args) {
System.out.println("LocalDateTime.now() " + LocalDateTime.now().toString());
System.out.println("LocalDateTime.now(ZoneId.of(\"Asia/Tokyo\") " + LocalDateTime.now(ZoneId.of("Asia/Tokyo")).toString());
System.out.println("LocalDateTime.now(ZoneId.of(\"GMT\") " + LocalDateTime.now(ZoneId.of("GMT")).toString());
}
}
Execution result (implemented at 14:33 on March 13, Japan time)
LocalDateTime.now() 2018-03-13T14:33:01.625
LocalDateTime.now(ZoneId.of("Asia/Tokyo") 2018-03-13T14:33:01.625
LocalDateTime.now(ZoneId.of("GMT") 2018-03-13T05:33:01.625
Recommended Posts