这个问题在这里已经有答案了:
以特定格式显示java.util.date(10个答案)
将java.time.localdate对象插入sql数据库(如h2)或从中获取java.time.localdate对象(1个答案)
希望当前日期和时间为“dd/mm/yyyy hh:mm:ss.ss”格式(10个答案)
上个月关门了。
我对将字符串格式化为'dd mmm yy'格式有问题。有人知道为什么它把字符串解析成完整格式而不是“dd-mmm-yy”吗。
String =
["01-Dec-20","02-Dec-20","03-Dec-20","04-Dec-20","05-Dec-20","06-Dec-20","07-Dec-20","08-Dec-20","09-Dec-20","10-Dec-20","11-Dec-20","12-Dec-20","13-Dec-20","14-Dec-20","15-Dec-20","16-Dec-20","17-Dec-20","18-Dec-20","19-Dec-20","20-Dec-20","21-Dec-20","22-Dec-20","23-Dec-20","24-Dec-20","25-Dec-20","26-Dec-20","27-Dec-20","28-Dec-20","29-Dec-20","30-Dec-20","31-Dec-20"]
对于字符串中的日期,我要转换为格式为“dd mmm yy”的日期
String dates = dateType.replace("\"", "").replace("[", "").replace("]", "");
List<String> stringList = new ArrayList<String>(Arrays.asList(dates.split(",")));
ArrayList<Date> dateList = new ArrayList<Date>();
stringList.forEach(d -> {
try {
Date date = new SimpleDateFormat("dd-MMM-yy").parse(d);
dateList.add(date);
} catch (ParseException e) {
e.printStackTrace();
}
});
日期列表将字符串转换为:
[Tue Dec 01 00:00:00 UTC 2020, Wed Dec 02 00:00:00 UTC 2020, Thu Dec 03 00:00:00 UTC 2020, Fri Dec 04 00:00:00 UTC 2020, Sat Dec 05 00:00:00 UTC 2020... etc ```
暂无答案!
目前还没有任何答案,快来回答吧!