Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9C1891337B5E for ; Thu, 6 Jan 2011 10:50:20 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 39260-08 for ; Thu, 6 Jan 2011 14:50:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm22.bullet.mail.sp2.yahoo.com (nm22.bullet.mail.sp2.yahoo.com [98.139.91.92]) by mail.postgresql.org (Postfix) with SMTP id 834641337B5D for ; Thu, 6 Jan 2011 10:50:12 -0400 (AST) Received: from [98.139.91.66] by nm22.bullet.mail.sp2.yahoo.com with NNFMP; 06 Jan 2011 14:50:11 -0000 Received: from [98.139.91.53] by tm6.bullet.mail.sp2.yahoo.com with NNFMP; 06 Jan 2011 14:50:10 -0000 Received: from [127.0.0.1] by omp1053.mail.sp2.yahoo.com with NNFMP; 06 Jan 2011 14:50:10 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 978062.46562.bm@omp1053.mail.sp2.yahoo.com Received: (qmail 42993 invoked by uid 60001); 6 Jan 2011 14:50:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1294325405; bh=yquSck/Zggot5Wf2MYcdEpCvp98mJfdeKx4lSvz3GWI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=4YrjtJ0bs79np+XZqhCc0xZbPs0RCs6WtNcivDWdKAw7dRc5vlBHESRfnAFmPsViAOIVgp/pZhFx534eWduRk6h3XhEBzwZJ7eOXM66n8rMgP3NQZkVPjr02hfEHCkfyIdEUO3dQdzDQSmJI25iZ8UffPHuLgBuBw5oN7l4N310= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=fwBn3GzBFUzPk9wEWRmQckFrVtzGsH+N5mrzHRIYwmGIXCZL5jNjLbZ8vBJScZF41wUb9A/RfNurSnjBHs1uH40FriD8Rd3wge3/A3fol6XNDcd9W6XWqvKIA/xvH0oFZL5Bh92kASPcCvHD6qjPPQLlBMURdDTjyg9mbmG1FuI=; Message-ID: <766302.42702.qm@web110412.mail.gq1.yahoo.com> X-YMail-OSG: jiUUkUwVM1ktjmy8UfcHr2U6GtboRFl8QCZVBWLeI90ijQg dZdALdreVrR_Um8JQbosGofrCtRu9d72_GlIM1HgVqXyR8dldtNVegTqlW9c K3wiLsaGeAnGqVZIx68jYkacwMkExKFsikNBQcM.1rnc5af9TgYNY_DDDY7R OcYTnXs7edyzAbms1x0BnY_2jH3g4YFyBRXptlBu9Ika7tsgbygX8C3ATDio MDEjQjmtilDuqFqVr9UqNvpPUQqI88osK1Qm9_cV1MlzKPz11vldgVf8JAEl IHDDy20X2.gqHdci3hVuKAt94OPVvRsKvlp_romDU5NtnB8TrM69aw6iqyqK oc_UwM4qgMUan7QfUk4sfS6oTQr9X0fWZj0iDDgeWLiO41HaKzEaTVo0tQ40 8rlu.Bo_7BNk- Received: from [119.152.117.151] by web110412.mail.gq1.yahoo.com via HTTP; Thu, 06 Jan 2011 06:50:04 PST X-Mailer: YahooMailRC/553 YahooMailWebService/0.8.107.285259 References: <416690.93407.qm@web110406.mail.gq1.yahoo.com> <4D257BC90200002500039054@gw.wicourts.gov> Date: Thu, 6 Jan 2011 06:50:04 -0800 (PST) From: Altaf Malik Subject: Re: Strange behaviour of rs.getTimestamp To: Kevin Grittner , pgsql-jdbc@postgresql.org In-Reply-To: <4D257BC90200002500039054@gw.wicourts.gov> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1339833582-1294325404=:42702" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.907 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/11 X-Sequence-Number: 21343 --0-1339833582-1294325404=:42702 Content-Type: text/plain; charset=us-ascii > So, what's different between the ones that yield the correct values > and the ones that don't? Please look at the values: 2009-04-15 00:00:00->2009-04-15 01:00:00.0 The value I inserted in table was 2009-04-15 00:00:00 and from rs.getString(1) I got the same value. rs.getTimestamp(1) returned me a different value (note the hour value is 1 instead of 0). The value I got is: 2009-04-15 00:00:00 > If you can put together a self-contained test case that someone can > compile and run on their own machine, it becomes much easier for > others to understand the problem and to help. I did so. Please read the following portion carefully: Statement stmt = con.createStatement(); stmt.executeUpdate("create table ts_test(a timestamp)"); stmt.executeUpdate("insert into ts_test values('15-APR-09');"); ResultSet rs = stmt.executeQuery("select * from ts_test"); while (rs.next()) { Timestamp t = rs.getTimestamp(1); System.out.println(rs.getString(1)+"->"+ t); } stmt.executeUpdate("drop table ts_test"); Regards, Altaf Malik --0-1339833582-1294325404=:42702 Content-Type: text/html; charset=us-ascii

> So, what's different between the ones that yield the correct values
> and the ones that don't?

Please look at the values:
2009-04-15 00:00:00->2009-04-15 01:00:00.0

The value I inserted in table was 2009-04-15 00:00:00 and from rs.getString(1) I got the same value. rs.getTimestamp(1) returned me a different value (note the hour value is 1 instead of 0). The value I got is: 2009-04-15 00:00:00


> If you can put together a self-contained test case that someone can
> compile and run on their own machine, it becomes much easier for
> others to understand the problem and to help.

I did so. Please read the following portion carefully:

    Statement stmt = con.createStatement();
        stmt.executeUpdate("create table ts_test(a timestamp)");
        stmt.executeUpdate("insert into ts_test values('15-APR-09');");
        ResultSet rs = stmt.executeQuery("select * from  ts_test");
        while (rs.next()) {
            Timestamp t = rs.getTimestamp(1);
            System.out.println(rs.getString(1)+"->"+ t);
        }
        stmt.executeUpdate("drop table ts_test");


Regards,
Altaf Malik

--0-1339833582-1294325404=:42702--