How do I convert 2010-12-15T16:26:49.841-08:00 to a GregorianCalendar in Java? [duplicate]
This question already has an answer here: Converting ISO 8601-compliant String to java.util.Date 27 answers I have a string date "2010-12-15T16:26:49.841-08:00" and I need to convert it to a GregorianCalendar in Java. How do you do this? Solution from Jesper's answer Code for the solution using joda time: DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").withOffsetParsed(); DateTime date = formatter.parseDateTime("2010-12-15T16:26:49.841-08:00"); Unfortunately, the standard SimpleDateFormat class cannot handle ISO 8601 format very well. Specifically, it