-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong Data Retrieval For Very Old Date Entries #17507
Comments
Thanks for your report. This seems to be a bug in H2 that won't be addressed there: You can reproduce it with JDBC directly: try (Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("select date '0001-01-01'")
) {
while (rs.next())
System.out.println(rs.getDate(1) + "/" + rs.getString(1) + "/" + rs.getObject(1, LocalDate.class));
}
try (PreparedStatement s = connection.prepareStatement("select ?")) {
s.setDate(1, Date.valueOf("0001-01-01"));
try (ResultSet rs = s.executeQuery()) {
while (rs.next())
System.out.println(rs.getDate(1) + "/" + rs.getString(1) + "/" + rs.getObject(1, LocalDate.class));
}
s.setObject(1, LocalDate.parse("0001-01-01"));
try (ResultSet rs = s.executeQuery()) {
while (rs.next())
System.out.println(rs.getDate(1) + "/" + rs.getString(1) + "/" + rs.getObject(1, LocalDate.class));
}
} In my time zone (CET), this produces:
A related issue: We should probably migrate towards using |
|
OK, so it's a feature |
With some time zones there is also an unrelated bug caused by a bug in JDK. But legacy datetime API in Java is broken in all possible ways. For example, there are four time zones where you can't represent midnight with TimeZone.setDefault(TimeZone.getTimeZone("America/Bahia_Banderas"));
System.out.println(java.sql.Time.valueOf("0:00:00").toString());
|
Expected behavior
If I write an old date with the value 0001-01-01 into a database, I expect the identical value to be returned in a corresponding query. This does not seem to be the case at the moment.
Actual behavior
The JOOQ data records do not match the expected values. 0001-01-03 is returned instead of the expected value 0001-01-01.
Even changing the data query in the following way does not change the result:
Steps to reproduce the problem
In the following example, four data records are generated and read using Java/SQL and Java/JOOQ.
JOOQ returns the following values:
Java/SQL , on the other hand, returns the following values:
jOOQ Version
jooq community (3.19.14)
Database product and version
h2 (2.3.232)
Java Version
openjdk 17 (17.0.4.1)
JDBC / R2DBC driver name and version (include name if unofficial driver)
No response
The text was updated successfully, but these errors were encountered: