Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure SimpleDateFormat is set to UTC timezone #468

Closed
wants to merge 2 commits into from

Conversation

gferon
Copy link
Contributor

@gferon gferon commented Jul 23, 2024

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

After spending quite some time trying to understand why our access tokens would not be refreshed, I realized that something was wrong with the expiresAt field. The issue affects (at least) Android because the UTC timezone is added in the format while the formatter itself is timezone-unaware.

With the following added print statements, you can observe that the Credentials.expiresAt is formatted from local time with an appended Z, which means we lose the timezone information.

I/System.out(18918): RenewApiRequestHandler::onSuccess credentials.expiresAt Tue Jul 23 08:49:05 GMT+02:00 2024
I/System.out(18918): RenewApiRequestHandler::onSuccess formattedDate 2024-07-23T08:49:05.555Z

Making sure all SimpleDateFormat are set to the UTC timezone fixes the issue, but since java.util.Date is notably confusing to work with, a better fix would maybe be to use java.time.Instant (see alternative PR #469) and either call .toInstant().toString() everywhere (and Instant.parse()) which always work with ISO-8601 representation.

📎 References

🎯 Testing

Print the expiresAt date in Flutter with and without this patch. This unit tests didn't catch this problem because the test had the same implementation issue.

@gferon gferon requested a review from a team as a code owner July 23, 2024 07:40
@gferon gferon changed the title [Android] Make sure SimpleDateFormat is set to UTC timezone Make sure SimpleDateFormat is set to UTC timezone Jul 23, 2024
@gferon gferon requested a review from a team as a code owner September 9, 2024 11:52
@desusai7
Copy link
Contributor

Hi @gferon,

We appreciate your time on raising this PR, however I am closing it as we are considering the PR #469 raised by you !

Thanks

@desusai7 desusai7 closed this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants