Skip to content

Incorrect timestamp format in AndroidNotification.event_time #337

Closed

Description

@hiranya911

I think the way we format the event_time field on AndroidNotification is wrong:

public Builder setEventTimeInMillis(long eventTimeInMillis) {
this.eventTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'")
.format(new Date(eventTimeInMillis));
return this;
}

There seems to be couple of issues with this.

  1. We are not specifying the timezone for the SimpleDateFormat. Therefore the resulting timestamp string is in the local timezone while the backend expects it to be in UTC.
  2. The way nanoseconds are formatted seems to be wrong. For the milliseconds value 1546304523123L this generates the string 2019-01-01T01:02:03.000000123Z. I would expect the nanos to be formatted as 123000000 (i.e. 123 milliseconds in nanos).

Activity

  1. chong-shao commented on Dec 19, 2019

    @chong-shao
    Contributor

    I think you are correct on both issues:

    1. Yes currently it formats based on the local timezone. Should change to UTC.
    2. I think RFC3339 does not specify how nanoseconds should be formatted. But in Java class SimpleDateFormat, 'S' means Milliseconds. So I think I should just format it into 'SSS' and append '000000' after the 'SSS'.

    Will add a fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions