Yesterday, I got into a problem with my work. On a Linux machine, I have a database (MySQL) table and there is a column in type time. I use the following java code to retrieve the value:
Time t = rs.getTime("columnName"); // rs is a ResultSet.
The Time objec is sent via HTTP to a GWT web application. The Time object is displayed correctly on a Firefox on linux (00:00:00) but not on a Firefox or IE on Windows (00:30:00).
No matter what value is in the database, the browsers on Windows will display it with an additional 30 mins.
Base on the javadoc, java.sql.Time is actually a Date object. The date related fields should be set to 1970-Jan-01 and left untouced. Only the time part of it is (should be) used. When the value is read from database, a Time object is created. It is set to 1970-Jan-01 (Asia/Kuala Lumur). Base on the tzdata, the offset for “Asia/Kuala Lumpur” on 1970-Jan-01 is only +7:30 instead of +8:00. Thus, the Time object will have the value -27000000 (which means 00:00:00 +0:00 on 1970-Jan-01).
To prove this: create a HTML file with the following content and open it with Firefox or epiphany on Linux, then do the same with IE or Firefox on Windows. Maybe another reason to use Linux instead of Windows:
var d = new Date();
document.write("Current Date offset (min) = ");
document.write("1970-Jan-01 offset (min) = ");