问题
I am running the following code:
DateFormat fullDate = new SimpleDateFormat("HHmmdd/MMMyy");
Date date = fullDate.parse("035627/NOV15");
and the following exception is thrown:
Exception in thread "main" java.text.ParseException: Unparseable date:"035627/NOV15
Any ideas, why the exception is thrown, while the format is validly stated?
回答1:
The likeliest reason is that NOV
is not a valid month in your default Locale. This should fix the problem (adjust the Locale to match the language used for the month name):
DateFormat fullDate = new SimpleDateFormat("HHmmdd/MMMyy", Locale.ENGLISH);
来源:https://stackoverflow.com/questions/33960608/parseexception-when-parsing-a-date