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

Loading a LocalDate results in timezones (wrongly) getting applied #1127

Open
nanella opened this issue Jan 13, 2022 · 1 comment
Open

Loading a LocalDate results in timezones (wrongly) getting applied #1127

nanella opened this issue Jan 13, 2022 · 1 comment
Assignees
Labels
in: mapping Mapping and conversion infrastructure theme: date-time Issues related to handling of date, time and timezone information type: bug A general bug

Comments

@nanella
Copy link

nanella commented Jan 13, 2022

Currently, using a java.time.LocalDate on an entity results in funny behaviour when loading it from the database (e.g. adding or removing a day depending on timezone), since the database result is converted to java.sql.Date before being converted to LocalDate, therefore adding in some timezone shenaningans. (See also #663 (comment), #663 (comment) and pgjdbc/pgjdbc#2221.)

Example with application in UTC+2 time-zone:

  • date to be saved (java.time.LocalDate.toString()): "1000-01-01"
  • field in database (postgres DATE type): "1000-01-01"
  • result when loading entity via spring-data-jdbc (java.time.LocalDate.toString()): "0999-12-31"

I may add a code example to reproduce once I find the time.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 13, 2022
@schauder schauder added type: enhancement A general enhancement status: waiting-for-triage An issue we've not yet triaged in: mapping Mapping and conversion infrastructure type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jan 19, 2022
@schauder
Copy link
Contributor

schauder commented Jan 20, 2022

As so often with dates there are more then one thing coming together here:

  1. The problem you describe is probably related to really funny stuff the date conversion does for dates in the distant past: https://stackoverflow.com/q/60429118/66686. And this seems to make it also depend on the exact timezone, not just the offset from UTC. We need to fix that. This issue should track that work.
  2. The conversion to java.sql.Timestamp really shouldn't happen after registering LocalDate as a simple datatype. But it still does. This will be tracked by The logic for converting values for writing is confusing and I think very wrong. #1136

@schauder schauder added the theme: date-time Issues related to handling of date, time and timezone information label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping Mapping and conversion infrastructure theme: date-time Issues related to handling of date, time and timezone information type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants