pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: tsayao (@tsayao) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #2834: LocalTime.MAX is more precise than postgresql, causing a possible overflow to the next day
Date: Tue, 28 Feb 2023 20:31:26 +0000
Message-ID: <[email protected]> (raw)
**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`
view thread (4+ 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 #2834: LocalTime.MAX is more precise than postgresql, causing a possible overflow to the next day
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