pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: Frank-Gu-81 (@Frank-Gu-81) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] issue #3692: Wrong time formatting ResultSet.getTime(); for Europe/Belgrade and "Europe/Prague"
Date: Thu, 21 Aug 2025 22:06:38 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Thanks for the discussion — following up with another observation that might help narrow this down.
## Context
I’m also seeing a possible time-of-day mismatch around DST when calling `ResultSet#getTime(int)` without a Calendar on `TIMESTAMP` / `TIMESTAMPTZ`.
## Environment
* PgJDBC: 42.7.7
* Java: 21
* PostgreSQL server: 16.4
* OS: macOS 15.6
* JVM default timezone at runtime: America/Los_Angeles
## Steps to reproduce
1. Set the JVM default zone to America/Los_Angeles (any DST-observing zone should work):
```java
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
2. Create a table and insert two rows (one in standard time, one in DST):
```sql
CREATE TEMP TABLE test_timestamps (
ts_without_tz timestamp,
ts_with_tz timestamptz
);
INSERT INTO test_timestamps VALUES
('2023-11-10 09:00:00', '2023-11-10 09:00:00-08'), -- PST (UTC-8)
('2023-03-13 09:00:00', '2023-03-13 09:00:00-07'); -- PDT (UTC-7)
```
3. Query and call `rs.getTime(col)` (no Calendar) on each column.
```java
try (var c = DriverManager.getConnection(PG_URL);
var s = c.createStatement();
var rs = s.executeQuery("select ts_without_tz, ts_with_tz from test_timestamps order by 1")) {
while (rs.next()) {
var tNoCal_noTz = rs.getTime(1); // no Calendar
var tNoCal_tz = rs.getTime(2); // no Calendar
var ts = rs.getTimestamp(2); // compare against local wall-clock at the instant
var lt = ts.toInstant().atZone(ZoneId.systemDefault()).toLocalTime();
System.out.printf("noCal timestamp=%s getTime=%s localTimeAtInstant=%s%n", ts, tNoCal_tz, lt);
}
}
```
## Observed vs expected (America/Los_Angeles)
* 2023-11-10 09:00 → `getTime(...)` returns 09:00:00 (as expected).
* 2023-03-13 09:00 → `getTime(...)` returns 08:00:00, while:
```java
var lt = ts.toInstant().atZone(ZoneId.systemDefault()).toLocalTime(); // → 09:00
```
shows 09:00 at that instant in the JVM zone.
## Possible cause
This seems consistent with the 1970-01-01 “epoch rebasing” noted earlier, and I think it's coming from the `PgResultSet#getTime(..)` path ending up in `TimestampUtils.convertToTime(...)`. Per its docs, `convertToTime()` normalizes the value so the date part becomes 1970-01-01 in the selected timezone.
view thread (8+ 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 #3692: Wrong time formatting ResultSet.getTime(); for Europe/Belgrade and "Europe/Prague"
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