This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes DB timestamp value with JVM TimeZone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB timestamp value with JVM TimeZone " Watch "DB timestamp value with JVM TimeZone " New topic
Author

DB timestamp value with JVM TimeZone

Ricky Ru
Greenhorn

Joined: Nov 05, 2012
Posts: 1
Dears,

If we have database timestamp "1970-01-01T16:00:00", no matter what Time Zone the jvm is running with, we get the java.sql.Timestamp object representing the time "1970-01-01T16:00:00" locally(Shang Hai, Las Vegas, London...). So, the UTC time will be different as well.

I need to do some conversion work to make database timestamp "1970-01-01T16:00:00" as UTC time. Although it will be different in jvms with different time zones, they all mean the same time(UTC time, same million seconds from UTC Time 1970-01-01T00:00:00.000) and will be consistent.

So, do you know how to convert a local java.sql.Timestamp to a UTC timestamp?(Actually, they're two different times.) For example, I want to convert java.sql.Timestamp("1970-0101T16:00:00+8:00") from database to java.util.Timestamp("1970-01-01T16:00:00UTC"). The literals are same.
 
wood burning stoves
 
subject: DB timestamp value with JVM TimeZone