From: David Wall <d.wall@computer.org>
To: pgsql-jdbc@lists.postgresql.org
Subject: Re: Java 8 OffsetDateTime clarification
Date: Tue, 7 May 2019 09:03:05 -0700
Message-ID: <6a7bfc0f-a0d4-b2f1-036c-cdbcbe6ff284@computer.org> (raw)
In-Reply-To: <qar7ho$4rfr$1@blaine.gmane.org>
References: <e0892e70-ffcb-6161-bbc9-3f710dd52593@computer.org>
<qar7ho$4rfr$1@blaine.gmane.org>
On 5/6/19 11:11 PM, Thomas Kellerer wrote:
> David Wall schrieb am 07.05.2019 um 04:31:
>> This seems incorrect to me.
>> The backend, when using TIMESTAMP WITH TIME ZONE, stores the
>> date+time+tzoffset
> No, it does not.
>
> From https://www.postgresql.org/docs/current/datatype-datetime.html
>
>> For timestamp with time zone, the internally stored value is always
>> in UTC (Universal Coordinated Time, traditionally known as Greenwich
>> Mean Time, GMT). An input value that has an explicit time zone
>> specified is converted to UTC using the appropriate offset for that
>> time zone. If no time zone is stated in the input string, then it is
>> assumed to be in the time zone indicated by the system's TimeZone
>> parameter, and is converted to UTC using the offset for the timezone
>> zone.
>>
>> When a timestamp with time zone value is output, it is always
>> converted from UTC to the current timezone zone, and displayed as
>> local time in that zone
Okay, yes, that's true. I shouldn't have used "store" as in what's
written to disk as that's not of interest to most users of a DB, other
then we expect to be able to order them in a meaningful way.
What I meant is that if we present it a date+time+tzoffset to JDBC, it
stores the correct date and time in the DB, not one off by the specified
tzoffset.
I don't change my OffsetDateTime variables to UTC before giving them to
JDBC, and the timestamps are stored and retrieved as expected.
This challenges the notion that "Also note that all OffsetDateTime
instances will have be in UTC (have offset 0)." is true, or am I just
getting unexpectedly normal results of PG without giving OffsetDateTime
instances in UTC?
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: d.wall@computer.org
Subject: Re: Java 8 OffsetDateTime clarification
In-Reply-To: <6a7bfc0f-a0d4-b2f1-036c-cdbcbe6ff284@computer.org>
References: <e0892e70-ffcb-6161-bbc9-3f710dd52593@computer.org> <qar7ho$4rfr$1@blaine.gmane.org> <6a7bfc0f-a0d4-b2f1-036c-cdbcbe6ff284@computer.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox