I am trying to convert a date String from the server to dateTime with ThreeTenBP. My method looks like this:
String toDateTime(String dateString) {
DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern("M/d/yyyy h:mm a").toFormatter();
ZonedDateTime dateTimeWithZone = ZonedDateTime.parse(dateString, formatter);
return dateTimeWithZone.toString();
}
However, I get an exception:
DateTimeParseException: Text '2015-07-21T09:26:06.260-05:00' could not be parsed at index 4
What am I doing wrong?