Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aNfMt-000477-IY for pgsql-jdbc@arkaria.postgresql.org; Mon, 25 Jan 2016 11:31:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aNfMs-0007Cr-Mh for pgsql-jdbc@arkaria.postgresql.org; Mon, 25 Jan 2016 11:31:34 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1aNfMN-0006d8-RT for pgsql-jdbc@postgresql.org; Mon, 25 Jan 2016 11:31:03 +0000 Received: from mail.netcetera.ch ([194.126.145.7] helo=mail.netcetera.com) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aNfMK-0007Rx-Ur for pgsql-jdbc@postgresql.org; Mon, 25 Jan 2016 11:31:03 +0000 Received: from netcetera.com (smtp-int.netcetera.com [172.16.0.139]) by mail.netcetera.com (8.13.8/8.14.1) with ESMTP id u0PBRnMw008083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 25 Jan 2016 12:27:50 +0100 Received: from exchange01.one.nca (exchange01.one.nca [172.16.1.20]) by netcetera.com (8.13.8/8.14.1) with ESMTP id u0PBRn5W024066 for ; Mon, 25 Jan 2016 12:27:49 +0100 Received: from malal.local (172.16.1.29) by exchange01.one.nca (172.16.1.20) with Microsoft SMTP Server (TLS) id 15.0.712.24; Mon, 25 Jan 2016 12:27:49 +0100 Subject: Re: Confusion about JDBC + TIME WITHOUT TIME ZONE To: References: <20160124190035.78da947487fa2559c162cdcf@potentialtech.com> From: Philippe Marschall Message-ID: <56A606AC.6020707@netcetera.ch> Date: Mon, 25 Jan 2016 12:27:40 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160124190035.78da947487fa2559c162cdcf@potentialtech.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [172.16.1.29] X-ClientProxiedBy: EXCHANGE02.one.nca (172.16.1.21) To exchange01.one.nca (172.16.1.20) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On 25.01.16 01:00, Bill Moran wrote: > > I have a table that has a TIME WITHOUT TIME ZONE column. > > When I try to insert via JDBC, the time is always adjusted for the > JVM's time zone. This behavior seems wrong to me. For example: > > // Java code: > preparedStatement.setTime(1, Time.valueOf("00:00:10")); > > Then, watching the PostgreSQL logs, I see that the value supplied > for parameter #1 is '05:00:10'. I am more leaning towards a bug. Can you try the following on a TIMESTAMP WITHOUT TIME ZONE column? preparedStatement.setTimestamp(1, java.sql.Timestamp.valueOf("2016-01-25 00:00:10")); If in that case the time (of the timestamp) stored is actually '00:00:10' then I would argue for a bug. The reasoning being: The java.sql date and time classes (Date, Time and Timestamp) are to be interpreted in the JVM default time zone in the case of WITHOUT TIME ZONE database types. For example: - For a TIMESTAMP WITHOUT TIME ZONE what in SQL is '2016-01-25 00:00:10' will be in Java java.sql.Timestamp 2016-01-25 00:00:10 in the JVM default time zone - For a DATE WITHOUT TIME ZONE what in SQL is '2016-01-25' will be java.sql.Date 2016-01-25 00:00:00 in the JVM default time zone (the time is added because java.util.Date instance implicitly always have a time) If the agree on this then it would make sense that - For a TIME WITHOUT TIME ZONE what in SQL is '00:00:10' will be java.sql.Time 1970-01-01 00:00:10 in the JVM default time zone (the date is added because java.util.Date instance implicitly always have a date and in this case 1970-01-01 is specified) Cheers Philippe -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc