Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.7.0
-
None
-
None
Description
If you pass more than 3 decimal places for the fractional seconds of the datetime, the microseconds get interpreted as milliseconds.
kafka-consumer-groups --bootstrap-server kafka:9092
--reset-offsets
--group webserver-avro
--topic driver-positions-avro
{{ --to-datetime "2020-11-05T00:46:48.002237400" }}
{{ --dry-run}}
Relevant code here. The datetime is being turned into Nov 5, 2020 1:24:05.400 because SimpleDateFormat is adding 2237400 milliseconds to Nov 5, 2020 00:46:48.
Experimenting with getDateTime:
- getDateTime("2020-11-05T00:46:48.000") -> 1604537208000
- getDateTime("2020-11-05T00:46:48.000+0800") -> 1604508408000 - correct the formatting string allows for ZZZ timezones
- getDateTime("2020-11-05T00:46:48.000123") -> 1604537208123 - note this ends with 123 milliseconds.
The pattern string is "yyyy-MM-dd'T'HH:mm:ss.SSS". So SimpleDateFormat interprets "000123" as 123 milliseconds. See the stackoverflow answer here.
The fix? Remove any digits after more than 3 characters after the decimal point, or raise an exception. The code would still need to allow the RFC822 timezone, i.e Sign TwoDigitHours Minutes.
Attachments
Issue Links
- links to