See the following test code (java 11):
public static final String DATE_FORMAT_TIMESTAMP = "YYYY-MM-dd'T'HH:mm:ss'Z'";
...
var timestamp = OffsetDateTime.now();
System.out.println(timestamp);
var formatter = DateTimeFormatter.ofPattern(DATE_FORMAT_TIMESTAMP);
var zt = timestamp.format(formatter);
System.out.println(zt);
...
The output:enter code here
2020-12-27T23:34:34.886272600+02:00
2021-12-27T23:34:34Z
Note formatted time year is 2021. And it happens only from 27/12, probably till 31/12.
Can someone explain this to me? And how do I fix the code to get the correct formatted string?