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 getTimeStamp() returns a UTC time 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 "getTimeStamp() returns a UTC time" Watch "getTimeStamp() returns a UTC time" New topic

getTimeStamp() returns a UTC time

Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
I am doing the following sequence of steps to get the time from a column in database.

Timestamp ts1 = rs.getTimeStamp(1);
Date myDate = new Date(ts1.getTime());

This returns me a time according to database locale, however i require the time accroding to the JVM's locale.

I guess there must be some conversion api's [is using calendar the solution?]
any pointers?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33108

It's actually just returning you a Date object which doesn't have a locale. Take a look at SimpleDateFormat for outputting it using different locales.

You mentioned UTC times. Do you mean timezones rather than locales?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: getTimeStamp() returns a UTC time
It's not a secret anymore!