Message-ID: From: "tsayao (@tsayao)" To: "pgjdbc/pgjdbc" Date: Tue, 28 Feb 2023 20:31:26 +0000 Subject: [pgjdbc/pgjdbc] issue #2834: LocalTime.MAX is more precise than postgresql, causing a possible overflow to the next day List-Id: X-GitHub-Assignees: davecramer X-GitHub-Author-Id: 30704286 X-GitHub-Author-Login: tsayao X-GitHub-Issue: 2834 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/2834 Content-Type: text/plain; charset=utf-8 **Describe the issue** I am using Hibernate (5.6.14) with Spring Data JPA and pgjdbc 42.5.4. When querying a column that is mapped to `LocalDateTime` with `LocalDate.atTime(LocalTime.MAX)` it returns results with the next day at 00:00:00.000000. `LocalTime.MAX` is implemented as: `MAX = new LocalTime(23, 59, 59, 999999999);` **Driver Version?** 42.5.4 **Java Version?** 17.0.4 **OS Version?** Linux Ubuntu 20.04 **PostgreSQL Version?** 14.5 **To Reproduce** ``` create table test ( col timestamp ); insert into test(col) values ('2023-03-01 00:00:00.000000'); insert into test(col) values ('2023-02-28 23:59:59.999999'); ``` ``` public class Main { public static void main(String[] args) throws Exception { String url = "jdbc:postgresql://localhost:5432/database"; Properties props = new Properties(); props.setProperty("user", "login"); props.setProperty("password", "pass"); try (Connection conn = DriverManager.getConnection(url, props)) { try (var stmt = conn.prepareStatement("select col from test where col = ?")) { stmt.setTimestamp(1, Timestamp.valueOf(LocalDate.of(2023, 2, 28).atTime(LocalTime.MAX))); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) System.out.println("Get String: " + rs.getString(1)); } } } } } ``` Prints out: `Get String: 2023-03-01 00:00:00`