Date 毫秒值 转换成时间格式的字符串

一:时间毫秒转换成格式化的字符串

1:添加依赖
<!--时间格式格式化 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>

2:
//当前时间的毫秒值
Long nowTimeMillisecond = 1560999418684L;
Date date = new Date();
date.setTime(nowTimeMillisecond);
String format = DateFormatUtils.format(date, "yyyy-MM-dd");
System.out.println(format);
//结果为 2019-06-20
posted @ 2019-06-20 11:16  Minde  阅读(4703)  评论(0编辑  收藏  举报