Questions tagged «java.time.instant»

7
在Java 8中有什么方法可以将ZoneId转换为ZoneOffset吗?
我通过method1有一个纪元和一个zoneId。它可以使用系统默认的zoneId转换为LocalDateTime,但是我找不到通过method2将纪元转换为LocalDateTime的方法,因为没有ZoneOffset.systemDefault。我认为它是晦涩的。 import java.time.{Instant, LocalDateTime, ZoneId, ZoneOffset} val epochSecond = System.currentTimeMillis() / 1000 LocalDateTime.ofInstant(Instant.ofEpochSecond(epochSecond), ZoneId.systemDefault())//method1 LocalDateTime.ofEpochSecond(epochSecond, 0, ZoneOffset.MAX)//method2
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.