I have a string:
String inputDate = "18-FEB-24 10.02.33.578000000 AM";
I am trying to read it back and format it in YYYY-MM-DD HH:mm:ss.SSSSSS. I tried the SimpleDateFormat as well as DateTimeFormatter libraries but not able to read it back. Below code from chatgpt but its getting error "String cannot parse at index 3"
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("dd-MMM-yy hh.mm.ss.SSSSSSSSS a", Locale.ENGLISH);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
LocalDateTime dateTime = LocalDateTime.parse(inputDate, inputFormatter);
String formattedDate = dateTime.format(outputFormatter);