boolean format = false; do { System.out.print("Enter time in: "); in = get.next(); try { LocalTime time = LocalTime.parse(in); DateTimeFormatter pattern = DateTimeFormatter.ofPattern("hh:mm a"); System.out.println(time.format(pattern)); format = true; } catch (Exception e) { format = false; JOptionPane.showMessageDialog(null, "Input invalid", "Error", JOptionPane.ERROR_MESSAGE); } }while(!format);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)