I'm trying to take in a date in 12H format and print it out in 24H format. Here's my code.
public static void main(String[] args)throws Exception {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss a");
Date date = sdf.parse(str);
System.out.println(sdf.format(date));
}
I keep getting the following error.
Exception in thread "main" java.text.ParseException: Unparseable date: "07:05:45PM"
at java.text.DateFormat.parse(DateFormat.java:366)
at Solution.main(Solution.java:12)