I'm trying to convert into HH:MM format in Java
Here is my code
String date = "18:30:00.000Z";
try {
ZonedDateTime parsed = ZonedDateTime.parse(date);
ZonedDateTime z = parsed.withZoneSameInstant(ZoneId.systemDefault());
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("hh:mm a", Locale.ENGLISH);
System.out.println(fmt.format(z));
} catch(Exception e) {
e.printStackTrace();
}
Is there anything wrong in my code
Here is the exception
java.time.format.DateTimeParseException: Text '18:30:00.000Z' could not be parsed at index 0