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

ISODate UTC timezone fixes #5037

Merged
merged 2 commits into from Oct 2, 2020
Merged

Conversation

jodygarnett
Copy link
Contributor

  • Fix ISODate parsing to respect use of Z suffix to indicate UTC timezone
  • Document ISODate constructor use of milliseconds against UTC timezone

For more information see #5016

@jodygarnett
Copy link
Contributor Author

jodygarnett commented Sep 23, 2020

This change identified some inconsistencies with ISODate constructors:

  • ISODate( milliseconds ) is expected to be in UTC (or GMT)
  • ISODate( milliseconds, shortDate ) use the current local timezone

As an example new ISODate( new ISODate(System.currentTimeMillis()) ) produces an ISODate in UTC timezone.

I am confident in this fix as many java classes (System,Date) work with a definition of:

The number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.

@jodygarnett
Copy link
Contributor Author

Discussion:

  • Q: Should these two methods be consistent in their use of either UTC or Local timezone?
  • Q: Does JPA persistence assume either UTC or Locale timezone?

@jodygarnett
Copy link
Contributor Author

Thanks @ianwallen I believe I have addressed your feedback.

@juanluisrp
Copy link
Contributor

  • Does JPA persistence assume either UTC or Locale timezone

Currently in the database dates don't contain timezone/offset so they are interpreted in the server local time when parsed by ISODate(String isoDate) constructor.

@jodygarnett
Copy link
Contributor Author

Thanks @juanluisrp, so we may of identified an additional QA activity in addition to this timezone consistency across the ISODate API - reporting as a separate feature request (#5040) rather than hold up this PR.

@jodygarnett
Copy link
Contributor Author

jodygarnett commented Sep 30, 2020

Currently in the database dates don't contain timezone/offset so they are interpreted in the server local time when parsed by ISODate(String isoDate) constructor.

To reply directly, this the ISODate(String isoDate) constructor is unchanged, so ISODates created by JPA are fine.

…of milliseconds

Signed-off-by: Jody Garnett <jody.garnett@gmail.com>
This prevents the tests failing due to location based ZoneId adjusting to daylight saving time changes over the course of hte year

Signed-off-by: Jody Garnett <jody.garnett@gmail.com>
@juanluisrp juanluisrp added the bug label Oct 2, 2020
@juanluisrp juanluisrp added this to the master milestone Oct 2, 2020
@juanluisrp juanluisrp merged commit 582d49f into geonetwork:master Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants