Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id DFE4E9FBAD7 for ; Wed, 14 Feb 2007 15:36:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 72895-05 for ; Wed, 14 Feb 2007 15:36:16 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 8139D9FB733 for ; Wed, 14 Feb 2007 15:36:16 -0400 (AST) Received: (qmail 16580 invoked by uid 1112); 14 Feb 2007 19:36:15 -0000 Date: Wed, 14 Feb 2007 14:36:15 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Floyd Shackelford cc: pgsql-jdbc@postgresql.org Subject: Re: bug report: preparedStatement.setObject(indx, "2004-August-15", java.sql.Types.DATE) generates number format exception In-Reply-To: <45D35D00.6020000@fwshackelford.com> Message-ID: References: <45D35D00.6020000@fwshackelford.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/65 X-Sequence-Number: 16621 On Wed, 14 Feb 2007, Floyd Shackelford wrote: > the following generates a number format exception: > preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) > > the following works: > preparedStatement.setObject(indx,"2004-08-15",java.sql.Types.DATE) > > i prefer to use the former. > I'm not sure that's actually a bug as there are many, many possible date formats and the JDBC spec doesn't specify what conversions must be supplied. Do you use this same code on other databases? Using a SimpleDateFormat object to convert from String to Date yourself is the most portable and guaranteed correct method. Kris Jurka