You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Russell Sayers (Jira)" <ji...@apache.org> on 2020/11/05 05:53:00 UTC

[jira] [Updated] (KAFKA-10685) --to-datetime passed to kafka-consumer-groups interpreting microseconds wrong

     [ https://issues.apache.org/jira/browse/KAFKA-10685?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Russell Sayers updated KAFKA-10685:
-----------------------------------
    Summary: --to-datetime passed to kafka-consumer-groups interpreting microseconds wrong  (was: --to-datetime passed to kafka-consumer-groups getting interpreted as a timezone)

> --to-datetime passed to kafka-consumer-groups interpreting microseconds wrong
> -----------------------------------------------------------------------------
>
>                 Key: KAFKA-10685
>                 URL: https://issues.apache.org/jira/browse/KAFKA-10685
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 2.7.0
>            Reporter: Russell Sayers
>            Priority: Minor
>
> 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|https://github.com/apache/kafka/blob/2.7/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L1304].
> 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|https://stackoverflow.com/a/21235602/109102].
> 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.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)