public static void main(String[] args) {
//获取时间戳方法一
long currentTimeMillis = System.currentTimeMillis();
//方法二
Instant instant = Instant.now();
long millisecond = instant.toEpochMilli();
//获取日期精确到毫秒
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String formattedTime = sdf.format(date);
System.out.println(formattedTime);
}
09-14
4913
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-01
2433
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-18
803
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交