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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM