Received: from sr14.nsw-remote.bigpond.net.au (sr14.nsw-remote.bigpond.net.au [24.192.3.29]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0ADFfB25570 for ; Wed, 10 Jan 2001 08:15:42 -0500 (EST) (envelope-from mcannon@internet.com) Received: from mikesmain (CPE-144-132-218-66.nsw.bigpond.net.au [144.132.218.66]) by sr14.nsw-remote.bigpond.net.au (Pro-8.9.3/8.9.3) with SMTP id AAA16317 for ; Thu, 11 Jan 2001 00:15:07 +1100 (EDT) From: "Mike Cannon-Brookes" To: "Pgsql-Interfaces@Postgresql. Org" Subject: RE: JDBC date problem Date: Thu, 11 Jan 2001 00:19:45 +1100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal In-Reply-To: X-Archive-Number: 200101/86 X-Sequence-Number: 695 For reference, I just updated my CVS tree and recompiled using Ant and the new jar works much better. It must be a bug in the old jar (ResultSet.java was indeed updated with your patch Michael). Thanks for the tip! Mike PS For anyone interested, org.postgresql.xa.Test has a serious bug in it, tries to instantiate an interface (XADataSource) - someone might want to hack at it. (just comment out the method and recompile if you care not about testing ;)) > -----Original Message----- > From: pgsql-interfaces-owner@postgresql.org > [mailto:pgsql-interfaces-owner@postgresql.org]On Behalf Of Michael > Stephenson > Sent: Wednesday, January 10, 2001 8:42 PM > To: Pgsql-Interfaces@Postgresql. Org > Subject: Re: [INTERFACES] JDBC date problem > > > > Any ideas? This is a real stumper and I need to find a solution > asap! I'm > > using a JDBC driver I built from CVS no more than a month ago. > > The results look to me like that in org.postgresql.jdbc2.ResultSet > 'mm' and 'MM' have been confused (I know that this was the case in a patch > I submitted), try replacing getTimeStamp() with: > > public Timestamp getTimestamp(int columnIndex) throws SQLException > { > String s = getString(columnIndex); > if(s==null) > return null; > > SimpleDateFormat df = null; > if (s.length()>21 && s.indexOf('.') != -1) { > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz"); > } else if (s.length()>19 && s.indexOf('.') == -1) { > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzz"); > } else if (s.length()>19 && s.indexOf('.') != -1) { > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); > } else if (s.length()>10 && s.length()<=18) { > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); > } else { > df = new SimpleDateFormat("yyyy-MM-dd"); > } > > try { > return new Timestamp(df.parse(s).getTime()); > } catch(ParseException e) { > throw new PSQLException("postgresql.res.badtimestamp",new > Integer(e.getErrorOffset()),s); > } > } > > Michael Stephenson > > >