I just try to parse a simple time! Here is my code:
String s = "01:19 PM";
Date time = null;
DateFormat parseFormat = new SimpleDateFormat("hh:mm aa");
try {
time = parseFormat.parse(s);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am getting this exception:
java.text.ParseException: Unparseable date: "01:19 PM"
at java.text.DateFormat.parse(Unknown Source)
This works:
public static void main(String[] args) throws Exception {
String s = "01:19 PM";
Date time = null;
DateFormat parseFormat = new SimpleDateFormat("hh:mm a", Locale.ENGLISH);
System.out.println(time = parseFormat.parse(s));
}
ouputs:
Thu Jan 01 13:19:00 KST 1970
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With