Skip to content

fix: make all Calendar instances proleptic Gregorian (#3837)#3887

Merged
davecramer merged 2 commits intopgjdbc:masterfrom
m-van-tilburg:3837-proleptic-gregorian
Dec 16, 2025
Merged

fix: make all Calendar instances proleptic Gregorian (#3837)#3887
davecramer merged 2 commits intopgjdbc:masterfrom
m-van-tilburg:3837-proleptic-gregorian

Conversation

@m-van-tilburg
Copy link
Contributor

@m-van-tilburg m-van-tilburg commented Dec 4, 2025

Calendar instances created with Calendar.getInstance() or new GregorianCalendar() are by default a hybrid of the Julian and the Gregorian calendar. Java classes like java.sql.Date and SimpleDateFormat also (sometimes) use Calendar instances and therefore might also be affected. This differs from the java.time classes that use the proleptic Gregorian calendar by default. The postgresql server also uses the proleptic Gregorian calendar and therefore it makes sense to make all Calendar instances in the pgjdbc code proleptic Gregorian too. This will fix #3837

Calendar instances created with Calendar.getInstance() or new GregorianCalendar() are by default a hybrid of the Julian and the Gregorian calendar. Java classes like java.sql.Date and SimpleDateFormat also (sometimes) use Calendar instances and therefore might also be affected. This differs from the java.time classes that use the proleptic Gregorian calendar by default. The postgresql server also uses the proleptic Gregorian calendar and therefore it makes sense to make all Calendar instances in the pgjdbc code proleptic Gregorian too.
Make TimestampUtils.createProlepticGregorianCalendar(TimeZone) public and use it in all other places too.
@m-van-tilburg
Copy link
Contributor Author

@davecramer do you have any review comments that I should address?

@davecramer davecramer merged commit 3609468 into pgjdbc:master Dec 16, 2025
18 checks passed
@m-van-tilburg m-van-tilburg deleted the 3837-proleptic-gregorian branch January 8, 2026 11:07
olavloite added a commit to GoogleCloudPlatform/pgadapter that referenced this pull request Jan 30, 2026
olavloite added a commit to GoogleCloudPlatform/pgadapter that referenced this pull request Jan 30, 2026
olavloite added a commit to GoogleCloudPlatform/pgadapter that referenced this pull request Jan 30, 2026
)

* build(deps): bump org.postgresql:postgresql from 42.7.8 to 42.7.9

Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.7.8 to 42.7.9.
- [Release notes](https://github.com/pgjdbc/pgjdbc/releases)
- [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md)
- [Commits](pgjdbc/pgjdbc@REL42.7.8...REL42.7.9)

---
updated-dependencies:
- dependency-name: org.postgresql:postgresql
  dependency-version: 42.7.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: relax test for pre-Gregorian dates

Change needed due to pgjdbc/pgjdbc#3887

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Knut Olav Løite <[email protected]>
davecramer added a commit that referenced this pull request Feb 6, 2026
davecramer added a commit that referenced this pull request Feb 6, 2026
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.

ResultSet.getTimestamp() returns incorrect point in time for historical dates

2 participants

Comments