Add support for a custom ZoneId in exposed-java-time
#1473
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements a ZoneId parameter for date related parameters in
exposed-java-time
. Currently Exposed uses the current system timezone, which can cause issues if you are inserting/selecting/etc dates in multiple machines that have different timezones.Before
Currently it is 16:25:40 in
America/Sao_Paulo
's (UTC-03) time zone.Output
After
Currently it is 16:27:01 in
America/Sao_Paulo
's time zone.Output
I haven't fully tested it yet, but...
America/Sao_Paulo
as the timezone, and the h2 and SQLite tests ran without any issues, even with the timezone modifications made in the tests to useUTC
instead of my local timezone.However it won't work if you are using a JDBC driver that does not support getting
LocalDateTime
. So I'm not sure if I still need to change more stuff. (Maybe add a fallback if the JDBC driver does not support it? I already had to add a fallback for the SQLite dialect.)Fixes #1356
Fixes #1305
Fixes #886
This does not use the
timestamp with timezone
type that some databases support (example: PostgreSQL)! The ZoneId is used to format the timestamp in your desired timezone.This does undo a lot of the things done in #1464 because we need to store a ZoneId for date formatting.
If this is good enough, I could try fixing
exposed-kotlin-datetime
later 😊.While we could default timestamps to
UTC
, thetimestamp without time zone
means just that: It is a timestamp without a time zone, not a timestamp in UTC, it is up to the application/developer to know what is the proper time zone of the timestamp.