Subject | Re: time zone problem |
---|---|
Author | rwilcom |
Post date | 2004-07-29T12:54:18Z |
Roman,
I believe I am setting the timezone correctly for the calendar
object - setting as follows:
private static final Calendar GMT = Calendar.getInstance
(TimeZone.getTimeZone("GMT") );
I am using the machine locale (which would be US/en) but that should
not impact the time zone. Reminder, if I change the OS timezone
setting the inserted date value changes!? This should never be the
case when using:
ps.setTimestamp(1, new java.sql.Timestamp( testDateTime.getTime()),
GMT );
Even if the calander object was wrongly set to a different timezone
the entry inserted into the database should be consistent even when
the OS timezone is changed. The driver should not relay on or use
the OS timezone setting to calculate the date/time entry from the
UTC millisec value?!
Also - I did upgrade to RC4 and the same problem occurs.
From my code snippet below you should easily be able to recreate
this problem. Please advise! Meanwhile, I will look into the JDBC
source code.
thanks,
Ron
start code snippet-----------------------
//assuming you have a connection object
//already connected via JayBird JDBC
Calendar GMT = Calendar.getInstance(TimeZone.getTimeZone
("GMT") ); //machine locale
PreparedStatement ps = null;
try {
ps = connection.prepareStatement("INSERT INTO MyTable(id,
dateAndtimeInGMT) VALUES (?, ?)");
ps.setInt(1, 1 );
Date testDate = format.parse("02-10-2004 10:00:00 EST");
ps.setTimestamp(2, new java.sql.Timestamp( testDate.getTime()),
GMT );
ps.executeUpdate();
//check the database value; this will be
//dependent on your OS time zone
//not on the GMT calculated value;
//After running this once change
//your OS time zone and run again -
//a different date/time value is inserted
}
catch (SQLException e){
System.out.println("error:"+e.toString());
}
finally{
try{ps.close();}
catch(Exception any){/*nothing*/}
}
end code snippet-----------------------
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
I believe I am setting the timezone correctly for the calendar
object - setting as follows:
private static final Calendar GMT = Calendar.getInstance
(TimeZone.getTimeZone("GMT") );
I am using the machine locale (which would be US/en) but that should
not impact the time zone. Reminder, if I change the OS timezone
setting the inserted date value changes!? This should never be the
case when using:
ps.setTimestamp(1, new java.sql.Timestamp( testDateTime.getTime()),
GMT );
Even if the calander object was wrongly set to a different timezone
the entry inserted into the database should be consistent even when
the OS timezone is changed. The driver should not relay on or use
the OS timezone setting to calculate the date/time entry from the
UTC millisec value?!
Also - I did upgrade to RC4 and the same problem occurs.
From my code snippet below you should easily be able to recreate
this problem. Please advise! Meanwhile, I will look into the JDBC
source code.
thanks,
Ron
start code snippet-----------------------
//assuming you have a connection object
//already connected via JayBird JDBC
Calendar GMT = Calendar.getInstance(TimeZone.getTimeZone
("GMT") ); //machine locale
PreparedStatement ps = null;
try {
ps = connection.prepareStatement("INSERT INTO MyTable(id,
dateAndtimeInGMT) VALUES (?, ?)");
ps.setInt(1, 1 );
Date testDate = format.parse("02-10-2004 10:00:00 EST");
ps.setTimestamp(2, new java.sql.Timestamp( testDate.getTime()),
GMT );
ps.executeUpdate();
//check the database value; this will be
//dependent on your OS time zone
//not on the GMT calculated value;
//After running this once change
//your OS time zone and run again -
//a different date/time value is inserted
}
catch (SQLException e){
System.out.println("error:"+e.toString());
}
finally{
try{ps.close();}
catch(Exception any){/*nothing*/}
}
end code snippet-----------------------
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
> > Date testDateTime= format.parse("02-10-2004 10:00:00 EST");()),
>
> > ps.setTimestamp(1, new java.sql.Timestamp( testDateTime.getTime
> > GMT );correctly (i.e.
>
> Please ensure that your GMT calendar has the time zone set
> it is not the default time zone). If you still believe that thereis a bug,
> please prepare a test case that reproduces the problem.org.firebirdsql.gds.XSQLVAR
>
> If you want to check sources, please see
> org.firebirdsql.jdbc.field.FBTimestampField and
> classes.
>
> Roman