I'm reading a datetime from database in the format 2017-04-20 11:01:21.053
, which I need to parse to the format 04/20/2017 11:01:21
I'm trying to parse this date on a LocalDateTime (Java 8) using the following code:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss.SSS");
LocalDateTime date = LocalDateTime.parse(dateToFormat, formatter);
But I get the following error when trying to parse 2017-04-20 11:01:21.053
:
Text '2017-04-20 11:01:21.053' could not be parsed at index 14
What am I doing wrong here?