| 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
|
|
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
|
 |
 |
|
|
subject: convert timestamp to date
|
|
|