How to parse the following date in UTC format 2013-01-12T12:00:00Z
using java
Asked
Active
Viewed 173 times
-1

Sam
- 8,387
- 19
- 62
- 97
-
SimpleDateFormat, but I failed – Sam Jan 25 '13 at 19:22
-
2@Sam show us your code . – PermGenError Jan 25 '13 at 19:23
-
1What's `T1e` in `2013-01-12T1e2:00:00Z`? – isvforall Jan 25 '13 at 19:33
-
1May be this will help? http://stackoverflow.com/questions/2201925/converting-iso8601-compliant-string-to-java-util-date – jdb Jan 25 '13 at 19:38
2 Answers
1
This works
System.out.println(
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
.parse("2013-01-12T102:00:00-0400"));

isvforall
- 8,768
- 6
- 35
- 50
-
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ"); Date date = formatter.parse("2013-01-12T12:00:00Z"); – Sam Jan 25 '13 at 19:41
-
-
@Sam `Z` - it's time zone, it can't be just letter `Z`. replace it to `-0400` – isvforall Jan 25 '13 at 19:59
-
0
In think SimpleDateFormat is what you need.
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(yourString)

Bastien Jansen
- 8,756
- 2
- 35
- 53