java8 获取当前时间戳

1、使用LocalDateTime架包

 LocalDate localDate = LocalDate.now();
 Timestamp timestamp= Timestamp.valueOf(LocalDateTime.now());
 System.out.println(timestamp.getTime());

结果是

2、使用Instant架包

Instant instant = Instant.now();
long timeStampMillis = instant.toEpochMilli();
System.out.println(timeStampMillis);

结果是

评论

h
hw_7864

⭐️ Admin快速开发: https://show.cool-admin.com/

赞 0
h
hw_7864

⭐️ 官方文档: https://cool-js.com

赞 0
h
hw_7864

⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld

赞 0