此问题是属于单纯的日期格式问题,直接上日期格式转换的代码:(转换后的日期可以直接作为条件使用mybatis进行条件查询)
public class DateUtil{
/**
* 将2019-06-03T16:00:00.000Z日期格式转换为2019-06-03 16:00:00格式
* @param oldDateStr
* @return
*/
public static Date transferDateFormat(String oldDateStr) {
if (StringUtils.isBlank(oldDateStr)){
return null;
}
Date date = null;
Date date1 = null;
String dateStr = null;
try {
dateStr = oldDateStr.replace("Z", " UTC");//是空格+UTC
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
date1 = df.parse(dateStr);
SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
date = df1.parse(date1.toString());
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
}

本文介绍了一种将特定日期格式(如2019-06-03T16:00:00.000Z)转换为标准格式(如2019-06-03 16:00:00)的方法,该方法适用于mybatis条件查询,通过使用SimpleDateFormat类实现日期格式的灵活转换。

487

被折叠的 条评论
为什么被折叠?



