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 1hCgEa-0000Hp-Qg for pgsql-jdbc@arkaria.postgresql.org; Sat, 06 Apr 2019 07:59:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hCgEZ-0002sg-2t for pgsql-jdbc@arkaria.postgresql.org; Sat, 06 Apr 2019 07:59:27 +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 1hCgEY-0002sZ-S9 for pgsql-jdbc@lists.postgresql.org; Sat, 06 Apr 2019 07:59:26 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCgEV-0004IZ-Hc for pgsql-jdbc@postgresql.org; Sat, 06 Apr 2019 07:59:25 +0000 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hCgET-000qDh-Cg for pgsql-jdbc@postgresql.org; Sat, 06 Apr 2019 09:59:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: ResultSet.getObject(..., LocalTime.class) not working with Postgres timetz type Date: Sat, 6 Apr 2019 09:59:13 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 X-Mozilla-News-Host: news://news.gmane.org:119 Content-Language: de-DE X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Retrieving the value of a timetz column fails when using getObject(, LocalTime.class) Consider the following code: Connection con = DriverManager.getConnection(...); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select current_time"); rs.next(); LocalTime lt = rs.getObject(1, LocalTime.class); The above fails with: org.postgresql.util.PSQLException: Bad value for type timestamp/date/time: {1} at org.postgresql.jdbc.TimestampUtils.toLocalTime(TimestampUtils.java:433) at org.postgresql.jdbc.PgResultSet.getLocalTime(PgResultSet.java:563) at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:3391) at TestLocalTime.main(TestLocalTime.java:23) Caused by: java.time.format.DateTimeParseException: Text '09:48:19.747249+02' could not be parsed, unparsed text found at index 15 at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952) at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851) at java.time.LocalTime.parse(LocalTime.java:441) at java.time.LocalTime.parse(LocalTime.java:426) at org.postgresql.jdbc.TimestampUtils.toLocalTime(TimestampUtils.java:430) getObject(1, OffsetTime.class) fails with "conversion to class java.time.OffsetTime from 92 not supported" I am not sure if this is the same as: https://github.com/pgjdbc/pgjdbc/issues/1048 If it's not the same root cause, should I create an issue? Using "select localtime" instead, works just fine Regards Thomas