I am trying to convert this date to a different format. unfortuantely havnt been successful parsing the date and retaining all the information correctly.
06-Dec-2017 07:14:56.656PM to 2017-12-06 19:14:56.656
If I try to parse the input date
LocalDateTime.parse("06-Dec-2017 07:14:56.656PM",
DateTimeFormatter.ofPattern("D-MMM-yyyy HH:mm:ss.SSSa"));
I get the following error - not sure what it means?
Exception in thread "main" java.time.format.DateTimeParseException: Text '06-Dec-2017 07:14:56.656PM' could not be parsed: Conflict found: Field MonthOfYear 1 differs from MonthOfYear 12 derived from 2017-01-06
at java.time.format.DateTimeFormatter.createError(Unknown Source)
at java.time.format.DateTimeFormatter.parse(Unknown Source)
at java.time.LocalDateTime.parse(Unknown Source)
at com.cordys.coe.alf.logger.DBLogger.main(DBLogger.java:366)
Caused by: java.time.DateTimeException: Conflict found: Field MonthOfYear 1 differs from MonthOfYear 12 derived from 2017-01-06
at java.time.format.Parsed.crossCheck(Unknown Source)
at java.time.format.Parsed.crossCheck(Unknown Source)
and if try
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS")
.format((new SimpleDateFormat("DD-MMM-yyyy HH:mm:ss.SSSa")
.parse("06-Dec-2017 07:14:56.656PM"))));
It give the following which is confusing, and probably not correct. 2017-01-06 07:14:56:656