pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: damixd1 (@damixd1) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3924: 0001-01-01 Date not properly saved in database and not properly red from database
Date: Mon, 02 Feb 2026 10:15:48 +0000
Message-ID: <[email protected]> (raw)

**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
                }
            }
        }
    }
}
```


view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3924: 0001-01-01 Date not properly saved in database and not properly red from database
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox