I am trying to convert a user-inputted String into hours, minutes, and seconds stored inside a Date object. Some code was borrowed from StackOverflow that uses a SimpleDateFormat object to parse the user input, but when it tries I get a ParseException.
System.out.println("Enter the start time of the event(hh:mm:ss): ");
String input = sc.next();
SimpleDateFormat f = new SimpleDateFormat("kk-mm-ss");
Date start = new Date();
try {
start = f.parse(input);
} catch (ParseException e) {
System.out.println("ERROR: Failed to parse start time.");
e.printStackTrace();
}
Exception
java.text.ParseException: Unparseable date: "01:02:03"
at java.text.DateFormat.parse(Unknown Source)
at Main.createDialog(Main.java:78)
at Main.displayMenu(Main.java:44)
at Main.main(Main.java:26)