The SimpleDateFormat:
SimpleDateFormat pdf = new SimpleDateFormat("MM dd yyyy hh:mm:ss:SSSaa");
The exception thrown by pdf.parse("Mar 30 2010 5:27:40:140PM");
:
java.text.ParseException: Unparseable date: "Mar 30 2010 5:27:40:140PM"
Any ideas?
Edit: thanks for the fast answers. You were all correct, I just missed that one key sentence in the SimpleDateFormat docs - I should probably call it a day.
From SimpleDateFormat javadocs:
Try to use pattern like "MMM dd yyyy"
First, three-char months are to be represented by
MMM
. Second, one-two digit hours are to be represented byh
. Third,Mar
seems to be English, you'll need to supply aLocale.ENGLISH
, else it won't work properly in machines with a different default locale.The following works:
Result (I'm at GMT-4 w/o DST):
Also see the
java.text.SimpleDateFormat
javadoc.Why you called it
pdf
is beyond me, so I renamed itsdf
;)MM stands for numeric month. Use MMM.