Description
Here is an excerpt from the ISO8601 norm (https://en.wikipedia.org/wiki/ISO_8601 - sorry could not find any official source) - in the Times section it says:
The basic format is [hh][mm][ss] and the extended format is [hh]:[mm]:[ss].
...
Decimal fractions may be added to any of the three time elements. However, a fraction may only be added to the lowest order time element in the representation.
So the following representation are accepted:
01.5
, means 1 hour and a half, i.e. equivalent to01:30:00
01:01.5
, means 1 hour, 1 minute and a half, i.e. equivalent to01:01:30
01:01:01.5
, means ..., i.e. equivalent to01:01:01.500
It is important to note the norm doesn't have the concept of millis but fraction of seconds. This is even better explained by the BNF presented in RFC3339 (https://www.ietf.org/rfc/rfc3339.txt), section 5.6 and/or appendix A.
Unfortunately, the way Jackson's StdDateFormat treats the fraction of seconds is not inline with the above.
00:00:00.5
is interpreted as00:00:00.005
, i.e. 5 millis instead of 0.5 seconds.00:00:00.1234
is interpreted as00:00:01.234
, i.e. 1234 millis which is equivalent to 1 sec and 234 millis.
These cases silently produce wrong date values - at least according to ISO8601 norm.
One can argue java.util.Date
as millis precision only and won't be able to cope with .1234
anyway. This is true, but not a reason to produces wrong result. It should either truncate to the first 3 digits (as does Joda) or refuse and throw an InvalidFormatException.
Issue described as of Jackson 2.8.9