JodaTime String yyyy-mm-ddThh:mmss.Z to DateTime

datetime, java, jodatime

Solution

For future visitors, simpler solution:

String date = "2014-02-16T00:17:20.000Z";
DateTime dateTime = new DateTime(date);

Problem

hi i am using Joda time to convert my string dates to DateTime objects. I currently have the following string: ``` 2014-02-16T00:17:20.000Z ``` how do i convert this to a DateTime object? I have tried: ``` DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZZZ"); DateTime dt = formatter.parseDateTime("2014-02-16T00:17:20.000Z"); ``` But i am getting the following error: ``` java.lang.IllegalArgumentException: Invalid format: "2014-02-16T00:17:20.000Z" is malformed at ".000Z" ``` Any help is greatly appreciated

Original source

Related problems