Formatting the date somehow is giving me an exception.
The date string that I want to convert to a Date object => 2019-12-12T15:31:31.000+0000
Code for converting which gives the error Text '2019-12-12T15:31:31.000+0000' could not be parsed at index 24
Date date;
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'+'Z");
ZonedDateTime formatDateTime = ZonedDateTime.parse(dateString,formatter);
date = Date.from(formatDateTime.toInstant());
return date.toString();
}catch (Exception ex){
return ex.getLocalizedMessage();
}
I'm not sure why this isn't working, the Date has been a huge problem for me in Java. In C# there's hardly any work that needs to be done but I couldn't figure out how to parse a date string in Java.
Help is appreciated, thanks people.