I need to convert a string to a Date object using SimpleDateFormat.
I use "MMM. dd yyyy" to parse strings like "Dec. 30 2011", with 3 month char and a dot.
It fails for "May 30 2011" so I have to catch the exception and re-try with "MMM dd yyyy". It works for "May", so far so ugly but works.
But when it get to "Sept. 11 2011", all of the above plus "MMMM. dd yyyy" and "MMMM dd yyyy" fail. So I can't parse it at all.
What is going on?
try this pattern -
MMM'.' dd yyyy
Code -
DateFormat df = new SimpleDateFormat("MMM'.' dd yyyy");
Date date = df.parse("Dec. 30 2011");
Hope it will help you to make fun :)
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