From: | Altaf Malik <mmalik_altaf(at)yahoo(dot)com> |
---|---|
To: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Strange behaviour of rs.getTimestamp |
Date: | 2011-01-06 14:50:04 |
Message-ID: | 766302.42702.qm@web110412.mail.gq1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2011-01-06 14:56:18 | Re: Strange behaviour of rs.getTimestamp |
Previous Message | Kevin Grittner | 2011-01-06 14:22:33 | Re: Strange behaviour of rs.getTimestamp |