When running the below code I get different behaviour with different versions of the JDK:
In Java 8 I get:
2020-01-07T09:34:38.994Z
In Java 11 I get:
2020-01-07T09:37:05.55126Z
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class MyClass {
public static void main(String args[]) {
ZonedDateTime now = ZonedDateTime.now();
DateTimeFormatter isoOffsetDateTime = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
String format = isoOffsetDateTime.format(now);
System.out.println(format);
}
}
Running in https://www.jdoodle.com/online-java-compiler/ just to make it easier to swap JDKs quickly
Is this change documented anywhere as I couldn't find anything and/or does anyone know why it's happening ? I spotted this as the DateTimeFormatter.ISO_OFFSET_DATE_TIME
is the default Jackson formatter for a ZonedDateTime
.