Writing a time value using a specific time zone

Graham Phillis <[email protected]> Sun, 05 Feb 2006 18:10:54 +0000
Newsgroups gmane.comp.db.mckoi
Message-ID <[email protected]>
I would like to write a time value to a table using a specific time 
zone, in this instance the UTC time zone.  To do this I am using the 
version of the prepared statement setTime method which takes a column 
index, SQL time value and a calendar object.  According to the javadoc I 
should be able to set the time zone of the calendar object and the 
database driver should use this time zone when writing the time value.  
Unfortunately it would appear the time value is still being written 
using the time zone of the JVM which in my case includes daylight 
savings time.  So when I try to write 9:00 am, I actually get 10:00 am 
written to the table!  Can someone please tell me where I'm going wrong 
or confirm this is bug.

The code I'm using is approximately as follows:

Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
prepareStatement.setTime(index, sqlTime, calendar);

The object sqlTime has a time value in milliseconds of 32,400,000 i.e. 
09:00:00, but as stated earlier I actually get the value '10:00:00' 
appearing in the table.

I hope this is enough information.

Regards
Graham




---------------------------------------------------------------
Mckoi SQL Database mailing list  http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]