String to ZonedDateTime is changing format
This is what toString from documentation said The format used will be the shortest that outputs the full value of the time where the omitted parts are implied to be zero. To solve this problem, you need another formatter : String result = mzt2.format(DateTimeFormatter.ofPattern(“yyyy-MM-dd’T’HH:mm:ss:SSS’Z'”)); Output 2011-05-01T11:47:35.422Z 2011-05-01T05:00:00:000Z