File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DB timestamp value with JVM TimeZone " Watch "DB timestamp value with JVM TimeZone " New topic

DB timestamp value with JVM TimeZone

Ricky Ru

Joined: Nov 05, 2012
Posts: 1

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.
I agree. Here's the link:
subject: DB timestamp value with JVM TimeZone
It's not a secret anymore!