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

Reading Postgresql pre-gregorian dates as LocalDates results in mismatching values #3363

Open
erkieh opened this issue Mar 21, 2025 · 5 comments

Comments

@erkieh
Copy link

erkieh commented Mar 21, 2025

Expected Behavior

Dates before 15 October 1582 are converted to LocalDates preserving the value

Actual Behaviour

Dates before 15 October 1582 are read back with a difference of +6 days.

Conversion seems to happen on

addZonedConvertorsConvertors(conversionService, java.sql.Date.class, date -> instantToZonedDateTime.apply(Instant.ofEpochMilli(date.getTime())));

Date and Instant epoch millis are handled differently before the Julian to Gregorian Calendar switch on 15th October 1582

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

4.12

@dstepanov
Copy link
Contributor

I think this issue was reported before and the solution is to have your app and your db in the same timezone.

Otherwise please provide a solution.

@erkieh
Copy link
Author

erkieh commented Mar 21, 2025

This is not about timezones. There will be a difference of 6 days if we use those old dates.

@radovanradic
Copy link
Contributor

The issue was with LocalDate shifting to one 1 day #2096 and it was fixed here #3248
This is something different and is related to the difference between Date and LocalDate calculating dates when Gregorian calendar was introduced. Not sure where we could add this fix.

@dstepanov
Copy link
Contributor

@erkieh Please provide an example project with Micronaut Data that is failing and an alternative in raw JDBC with a date conversions that don't have this error.

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

No branches or pull requests

3 participants