作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我有两个日期需要格式化,但我收到以下异常。我的主要问题是白天部分的 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"
我是一名优秀的程序员,十分优秀!