Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hO2Ym-0001m9-DS for pgsql-jdbc@arkaria.postgresql.org; Tue, 07 May 2019 16:03:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hO2Yl-0007RE-0B for pgsql-jdbc@arkaria.postgresql.org; Tue, 07 May 2019 16:03:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hO2Yk-0007R7-Ox for pgsql-jdbc@lists.postgresql.org; Tue, 07 May 2019 16:03:14 +0000 Received: from smtp72.ord1c.emailsrvr.com ([108.166.43.72]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hO2Yg-0002ad-63 for pgsql-jdbc@lists.postgresql.org; Tue, 07 May 2019 16:03:14 +0000 Received: from smtp18.relay.ord1c.emailsrvr.com (localhost [127.0.0.1]) by smtp18.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id AF1A1E02FC for ; Tue, 7 May 2019 12:03:06 -0400 (EDT) X-Auth-ID: david.wall@myeastside.com Received: by smtp18.relay.ord1c.emailsrvr.com (Authenticated sender: david.wall-AT-myeastside.com) with ESMTPSA id 14EC9E0234 for ; Tue, 7 May 2019 12:03:05 -0400 (EDT) X-Sender-Id: david.wall@myeastside.com Received: from [10.138.21.190] (50-46-124-128.evrt.wa.frontiernet.net [50.46.124.128]) (using TLSv1.2 with cipher AES128-SHA) by 0.0.0.0:465 (trex/5.7.12); Tue, 07 May 2019 12:03:06 -0400 Subject: Re: Java 8 OffsetDateTime clarification To: pgsql-jdbc@lists.postgresql.org References: From: David Wall Message-ID: <6a7bfc0f-a0d4-b2f1-036c-cdbcbe6ff284@computer.org> Date: Tue, 7 May 2019 09:03:05 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------FC55F01B3A3413AFB0DE2D22" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------FC55F01B3A3413AFB0DE2D22 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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? --------------FC55F01B3A3413AFB0DE2D22 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit 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? --------------FC55F01B3A3413AFB0DE2D22--