Converting iso8601 date to unix timestamp in java

datetime, iso8601, java

Solution

`X` is used for `ISO 8601 time zone` in `SimpleDateFormat`, not `Z`

Correct format is `"yyyy-MM-dd'T'HH:mm:ss.SSSX"`

Problem

I have a date string ``` String s = "2014-09-01T19:22:43.000Z"; Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(s); ``` But I get an exception: ``` Exception in thread "main" java.text.ParseException: Unparseable date: "2014-09-01T19:22:43.000Z" ``` How do I convert the above string to unix timestamp? Thanks

Original source

Related problems