<分区>
我有两个日期需要格式化,但我收到以下异常。我的主要问题是白天部分的 th rd etc
。我找不到这个问题的任何答案。我检查了所有这些链接 1 , 2 , 3 , 4 , 5我想我应该使用正则表达式,但不确定如何使用。
10th Dec 2019 -> 2019-12-10
10th December 2019 -> 2019-12-10
代码
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 in thread "main" java.text.ParseException: Unparseable date: "10th Dec 2019"