Received: from mail1.panix.com (mail1.panix.com [166.84.0.212]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA62979 for ; Sat, 3 Jun 2000 12:17:26 -0400 (EDT) (envelope-from nissim@nksystems.com) Received: from nksystems.com (remote-nksystems-gw.nyc.dsl.access.net [166.84.151.226]) by mail1.panix.com (Postfix) with ESMTP id E631330FD5 for ; Sat, 3 Jun 2000 12:17:25 -0400 (EDT) Message-ID: <39392E5F.8AF61D0E@nksystems.com> Date: Sat, 03 Jun 2000 12:12:15 -0400 From: Nissim X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.13-4mdk i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@hub.org Subject: JDBC setTimestamp/getTimestamp Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200006/14 Hi, if you do Calendar cal = Calendar.getInstance(); cal.setTime( new java.util.Date() ); stmt.setTimeStamp( 1, new java.sql.Timestamp( cal.getTime().getTime() ) ); where param 1 is a column with datatype timestamp. And then you do rset.getTimeStamp( 1 ); to select the same column, you get an exception, because the setTimeStamp did a toString() on the java.sql.Timestamp, which returns "yyyy-mm-dd hh:mm:ss.fffffffff". Then the select statement will return something like this: "2000-06-03 11:47:47.85-04" and the getTimeStamp tries to shove thaat into a SimpleDateFormat initialized with this: "yyyy-MM-dd HH:mm:sszzz". Would the following be a bad way to fix this? Check if the string with the date value contains "." and then use a different format string. I think it would probably be better if the server always returned "yyyy-MM-dd HH:mm:ss.SSSzzz" regardless of whether milliseconds were specified in the Insert/Update. -Nissim