I am attempting to parse a date String but get this error:
java.text.ParseException: Unparseable date: "Oct 1, 1997, 12:00:00 AM"
This is the method I am using to parse the Date
:
public static Date parse(@NonNull String dateString, @NonNull String dateFormat) {
val sdf = new SimpleDateFormat(dateFormat);
sdf.setLenient(false);
try {
return sdf.parse(dateString);
} catch (ParseException e) {
return null;
}
}
Where the dateString
is Oct 1, 1997, 12:00:00 AM
and the dateFormat
is MMM d, yyyy, HH:mm:ss a
.
Why is it failing to parse the date?