I have a string-date “31-Dec”, and pattern “dd-MMM”. And the next code
DateFormat formatter = new SimpleDateFormat(pattern);
formatter.setTimeZone(timeZone);
formatter.parse(input);
generates exception
java.text.ParseException: Unparseable date: "31-Dec"
at java.text.DateFormat.parse(DateFormat.java:337)....
What did I do wrong?
Thanks!
One problem could be that your
Localeis not english. Try this:This returns for me:
As you are missing a year in your date string, you see that it automatically inserts
1970as year.