Message-ID: From: "damixd1 (@damixd1)" To: "pgjdbc/pgjdbc" Date: Mon, 02 Feb 2026 10:15:48 +0000 Subject: [pgjdbc/pgjdbc] issue #3924: 0001-01-01 Date not properly saved in database and not properly red from database List-Id: X-GitHub-Assignees: davecramer X-GitHub-Author-Id: 170560968 X-GitHub-Author-Login: damixd1 X-GitHub-Issue: 3924 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3924 Content-Type: text/plain; charset=utf-8 **Describe the issue** `ResultSet.getDate` or `ResultSet.getTimestamp` returns not correct date when reading value `0001-01-01` (`DATE` column type) from database, is it red like `0000-01-03`. When you want to save `0001-01-01` value in database (`DATE` column type) is is saved as `0001-12-30 BC` (Before Christus). Might have been caused by https://github.com/pgjdbc/pgjdbc/pull/3887 **Driver Version?** 42.7.9 **Java Version?** 21 **OS Version?** Windows 11 / Linux **PostgreSQL Version?** 14.17 **To Reproduce** Steps to reproduce the behaviour: Put the value `0001-01-01` in a `DATE` column Execute a query that selects the `DATE` column Use `ResultSet.getTimestamp()` or `ResultSet.getDate()` to get the value **Expected behaviour** Correct historical date is returned or saved. **Reproduction source code** ``` import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Properties; import java.sql.Timestamp; import java.time.LocalDate; import java.sql.Date; public class TestDate { public static void main(String []args) throws Exception { String url = "jdbc:postgresql://localhost:5432/test"; Properties props = new Properties(); props.setProperty("user", "test"); props.setProperty("password", "test"); try ( Connection conn = DriverManager.getConnection(url, props) ){ try ( Statement statement = conn.createStatement() ) { try (ResultSet rs = statement.executeQuery( "SELECT DATE_COLUMN FROM EXAMPLE_TABLE WHERE ID = 1") ){ //Retrives value 0001-01-01 already persisted in database if (rs.next()) System.out.println( "Get Date: " + rs.getDate(1)); //Returns 0001-01-03 System.out.println( "Get Timestamp: " + rs.getTimestamp(1)); //Returns 0001-01-03 00:00:00 System.out.println( "Get LocalDate: " + rs.getObject(1, LocalDate.class)); //Returns 0001-01-01 } } } } } ```