java时间时间转换去掉毫秒
2017-10-15 本文已影响0人
qzuser_8572
最近工作中遇到时间不去掉毫秒,临界值判断不对,去掉毫秒
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private Date covertTime(Date date) {
Timestamp now = new Timestamp(date.getTime());
String str = df.format(now);
Date newDate = null;
try {
newDate = df.parse(str);
} catch (ParseException e) {
throw new BusinessException("转换日期去掉毫秒异常");
}
return newDate;
}