On Fri, 22 Apr 2005, Oliver Jowett wrote:

> Ingolf Knopf wrote:
> > Bug reference:      1611
> > PostgreSQL version: 8.0.1
> > Operating system:   JDBC
> > Description:        reading a date-field by "ResultSet.getTimestamp()"
> > method analized dayligth flag
> > Details: 
> > 
> > Retrieving data by "java.sql.ResultSet" I read a data from a column which
> > has type DATE. I read content of this column by method
> > "ResultSet.getTimestamp( int )".
> > I get a "java.sql.Timestamp"-object, where Calendar.HOUR_OF_DAY==1. I
> > suppose, this is daylight flag.
> > 
> > Maybe this behavior of your JDBC driver is compatible with SQL standard, but
> > it is completely other than the behavior of "Oracle" or "Ingres".
> 
> Can you provide a compilable test case please?

I wrote this test, but I haven't really thought about what to do with it 
yet.  For me it shows:

2005-04-20
2005-04-20 16:00:00.0
420
2005-11-20
2005-11-20 16:00:00.0
480

Kris Jurka
import java.sql.*;

public class DateToTS {
        public static void main(String args[]) throws Exception {

                Class.forName("org.postgresql.Driver");
                Connection conn = 
DriverManager.getConnection("jdbc:postgresql://localhost:5810/jurka","jurka","");

                Statement stmt = conn.createStatement();
                stmt.executeUpdate("CREATE TEMP TABLE datetest (a date)");
                stmt.executeUpdate("INSERT INTO datetest VALUES 
('2005-04-20')");
                stmt.executeUpdate("INSERT INTO datetest VALUES 
('2005-11-20')");
                ResultSet rs = stmt.executeQuery("SELECT * FROM datetest");
                while (rs.next()) {
                        System.err.println(rs.getString(1));
                        System.err.println(rs.getTimestamp(1));
                        
System.err.println(rs.getTimestamp(1).getTimezoneOffset());
                }

                rs.close();
                stmt.close();
                conn.close();
        }
}
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to