简体   繁体   中英

Which time zone is used by java.sql.Timestamp(long)?

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 ?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM