I tried the following pattern with new SimpleDateFormat(pattern).parse("Nov 17, 2016 7:26:57 PM")
but none of them work:
MMM d, yyyy h:m:s a
MMM dd, yyyy HH:mm:ss a
MMM dd, yyyy h:m:s a
The only way I can parse this string successfully is to use new Date("Nov 17, 2016 7:26:57 PM")
but this call is obsolete. It is said to be replaced by DateFormat.parse()
according to the API documentation but actually it failed to parse the same string when I call DateFormat.getDateTimeInstance().parse("Nov 17, 2016 7:26:57 PM")
. So how should I parse this string correctly other than using new Date()
?