That's not the correct format for parsing that date, you need something like:
"hh:mm a"
Once you have a date object, you can then use a different format to output it. The following code segment shows how:
import java.text.SimpleDateFormat;
import java.util.Date;
String date = "09:27 PM";
SimpleDateFormat h_mm_a = new SimpleDateFormat("h:mm a");
SimpleDateFormat hh_mm_ss = new SimpleDateFormat("HH:mm:ss");
try {
Date d1 = h_mm_a.parse(date);
System.out.println (hh_mm_ss.format(d1));
} catch (Exception e) {
e.printStackTrace();
}
This outputs:
21:27:00
as you would expect.