Reputation: 23871
When building a SQL time stamp by specifying only the milliseconds in the constructor, which time zone will be used? And how to choose whether UTC or the local time zone will be written into an Oracle data base column of the type TIMESTAMP(6) WITH LOCAL TIME ZONE
?
Upvotes: 1
Views: 1071
Reputation: 7287
Timestamp(int year, int month, int date, int hour, int minute, int second, int nano)
Timestamp(long time) - time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
There is no timezone in timestamps
In general if a timezone is assumed, it would be jvm default (system default)
oracle data types are a different beast
See
Timezones in SQL DATE vs java.sql.Date
Oracle 10g Time Zone Confusion - there are 3 timezones in play
when working with database please use Calendar or java.sql.Date
the oracle driver (and sql developer) may convert (its smart) dates from jvm timezone (or strictly speaking, session timezone) to what it needs to be
you can change session timezone with - alter session set time_zone... How to get UTC value for SYSDATE on Oracle
be careful with what you are doing though
write 10 different test cases
this blog is nice too http://tonyhasler.wordpress.com/2010/09/04/tonys-tirade-against-timestamp-with-time-zone/
Upvotes: 2