将时间戳转换为LocalDateTime:可以使用Instant类的ofEpochMilli方法将时间戳转换为Instant对象,然后再使用Instant对象的atZone方法将其转换为特定时区的ZonedDateTime对象,最后再调用ZonedDateTime对象的toLocalDateTime方法将其转换为LocalDateTime对象。
将LocalDateTime转换为时间戳:可以使用LocalDateTime对象的atZone方法将其转换为特定时区的ZonedDateTime对象,然后再调用ZonedDateTime对象的toInstant方法将其转换为Instant对象,最后再调用Instant对象的toEpochMilli方法将其转换为时间戳。
获取当前时间戳:可以使用System.currentTimeMillis()方法获取当前时间的时间戳。
获取当前时间的LocalDateTime对象:可以使用LocalDateTime.now()方法获取当前时间的LocalDateTime对象。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Java Calendar类中的时间操作方法有哪些