aspose file tools
The moose likes Java in General and the fly likes convert timestamp to date Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "convert timestamp to date " Watch "convert timestamp to date " New topic
Author

convert timestamp to date

kumar inuks
Greenhorn

Joined: Dec 02, 2009
Posts: 4
how can I convert "2006-08-15T17:23:15Z" to Date object
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Have you looked at the JavaDoc for SimpleDateFormat?


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
kumar inuks
Greenhorn

Joined: Dec 02, 2009
Posts: 4
I found a solution , here it is
String str = "2006-08-15T17:23:15Z";
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
Date date= (Date) df.parse(str);
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12907
    
    3

Note that the 'Z' at the end of that timestamp indicates that the date and time are to be interpreted as "zulu time", which means they are in the UTC timezone. You might want to take that into account when dealing with it.

You can set the timezone on the SimpleDateFormat object, like this:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
kumar inuks
Greenhorn

Joined: Dec 02, 2009
Posts: 4
thanks Jesper
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: convert timestamp to date
 
Similar Threads
DATE/TIME
conversion
how to convert String into Date format
String conversion
jstl miliseconds to Date