Request:
Timezone support for the timestamp data type (and probably for the date data type and the time data type as well) would be very useful for some DbUnit users.
Analysis:
Currently, timezones are not supported since the parsing effort is being delegated to java.sql.Timestamp.valueOf() which cannot handle timezones. Actually, Timestamp.valueOf() silently uses the default timezone. This can lead to surprising results. Consider the following code and the two different outputs, depending on the default timezone:
System.out.println( "jvm's timezone: " + TimeZone.getDefault().getID() );
String input = "2007-12-05 10:00:00.000000000";
Timestamp ts = Timestamp.valueOf( input );
System.out.println( input + "'s is " + ts.getTime() + " milliseconds since January 1, 1970, 00:00:00 GMT" );
- with the default timezone of my system:
jvm's timezone: Europe/Zurich
2007-12-05 10:00:00.000000000 is parsed to be 1196845200000 milliseconds since January 1, 1970, 00:00:00 GMT
- in UTC:
jvm's timezone: UTC
2007-12-05 10:00:00.000000000 is parsed to be 1196848800000 milliseconds since January 1, 1970, 00:00:00 GMT
(credit to Guillaume Cottenceau, see http://archives.postgresql.org/pgsql-jdbc/2007-12/msg00014.php\)
Solution:
Use java.text.DateFormat.parse() instead. See attached patch.
Timezone support for timestamp data type patch
Done in svn:1131.