I have two dates as following that need to format them but I am receiving following exception. My main issue is with the th rd etc
in the day part. I could not find any answer for this question. I checked all these links 1,2,3,4,5 I think I should use Regex but not sure how.
10th Dec 2019 -> 2019-12-10
10th December 2019 -> 2019-12-10
Code
String date1 = "10th Dec 2019";
Date date = new SimpleDateFormat("dd MMMM YYYY").parse(date1);
System.err.println(date);
String date2 = new SimpleDateFormat("yyyy-mm-dd").format(date);
System.err.println(date2);
Exception
Exception in thread "main" java.text.ParseException: Unparseable date: "10th Dec 2019"