美文网首页
java时间时间转换去掉毫秒

java时间时间转换去掉毫秒

作者: qzuser_8572 | 来源:发表于2017-10-15 18:34 被阅读0次

最近工作中遇到时间不去掉毫秒,临界值判断不对,去掉毫秒

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;
    }

相关文章

网友评论

      本文标题:java时间时间转换去掉毫秒

      本文链接:https://www.haomeiwen.com/subject/uxbcuxtx.html