jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Java time & date API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java time & date API " Watch "Java time & date API " New topic

Java time & date API

shikhi sharma

Joined: Jul 20, 2009
Posts: 1

I get started = "2009-07-20T11:04:02-07:00" time string from the server. I know the current device location is Newyork (lon="-73.805687" lat="40.682949"). The way C# code handles it is,

DateTime Started = Convert.ToDateTime(Reader["Started"]);

if(Reader["TimeZoneOffset"] != DBNull.Value)
TimeZoneOffset = Convert.ToInt32(Reader["TimeZoneOffset"]);

And, i display Started : 7/20/2009 2:04 PM

How can this same thing be done in JAVA? Please help!!


K. Tsang

Joined: Sep 13, 2007
Posts: 3062

Welcome to the ranch.

Try looking at the java.text.SimpleDateFormat class.

K. Tsang JavaRanch SCJP5 SCJD OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
I agree. Here's the link: http://aspose.com/file-tools
subject: Java time & date API
It's not a secret anymore!