From: Mike Cannon-Brookes <mcannon@internet.com>
To: Pgsql-Interfaces@Postgresql. Org <pgsql-interfaces@postgresql.org>
Subject: RE: JDBC date problem
Date: Thu, 11 Jan 2001 00:19:45 +1100
Message-ID: <NCBBKLKCHGCKLBAFEDFDOEGPHJAA.mcannon@internet.com> (raw)
In-Reply-To: <Pine.LNX.4.30.0101100935480.1704-100000@tirin.openworld.co.uk>
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
>
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: mcannon@internet.com
Subject: RE: JDBC date problem
In-Reply-To: <NCBBKLKCHGCKLBAFEDFDOEGPHJAA.mcannon@internet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox