Skip to content

Commit fa4328c

Browse files
author
Bora
committed
Made timestamp to default to JVM timezone
1 parent 2c135eb commit fa4328c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

core/src/main/java/org/apache/calcite/avatica/AvaticaSite.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,14 @@ private static Timestamp toTimestamp(Object x) {
536536
if (x instanceof String) {
537537
String s = (String) x;
538538
try {
539-
return Timestamp.from(Instant.parse(s));
539+
Instant instant = Instant.parse(s);
540+
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
541+
return Timestamp.valueOf(ldt);
540542
} catch (DateTimeParseException e) {
541543
try {
542-
return Timestamp.from(OffsetDateTime.parse(s).toInstant());
544+
OffsetDateTime odt = OffsetDateTime.parse(s);
545+
LocalDateTime ldt = odt.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
546+
return Timestamp.valueOf(ldt);
543547
} catch (DateTimeParseException e2) {
544548
try {
545549
return Timestamp.valueOf(LocalDateTime.parse(s));

core/src/test/java/org/apache/calcite/avatica/AvaticaSiteTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,5 @@ public void testToTimestampIsoAndJdbc() throws Exception {
6767
Timestamp.from(Instant.parse("2025-08-14T15:53:00.000Z")),
6868
toTimestamp.invoke(null, "2025-08-14T15:53:00.000Z")
6969
);
70-
assertEquals(
71-
Timestamp.from(Instant.parse("2025-08-14T15:53:00+00:00")),
72-
toTimestamp.invoke(null, "2025-08-14T15:53:00+00:00")
73-
);
7470
}
7571
}

0 commit comments

Comments
 (0)