I am calling a web service that formats dates using ISO-8601 (as far as I can tell).
Here is the pattern I am using the parse the dates (I'm using Jackson to de-serialize the response):
yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
Most of the time, the service returns dates that look like this:
2022-08-19T22:48:17.228Z
However, the service occasionally returns a date like this:
2023-09-12T00:18:25Z
I think this occurs when the number of milliseconds is exactly 0.
Is this expected behavior for ISO-8601 dates, or is the service doing something weird?
According to this
Meaning that the "mask" used by the service considers the 3rd digit of the milliseconds to be optional, and when it is 0 it will hide the value altogether.
A fix would be to check the length of the date and add a 0 before the last character (assuming its always Z)