java LocalDateTime parsing exception for date having pattern MM/d/yyyy HH:mm:ss a
问题 I am getting exception while executing below code i am using java datetime APIs. String strDate = "12/4/2018 5:26:28 PM"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/d/yyyy HH:mm:ss a", Locale.ENGLISH); LocalDateTime localDateTime = LocalDateTime.parse(strDate, formatter); below exception is coming Exception in thread "main" java.time.format.DateTimeParseException: Text '12/4/2018 5:26:28 PM' could not be parsed at index 10 at java.time.format.DateTimeFormatter