1689561881 转为 LocalDateTime 格式
To convert the given number 1689561881 to LocalDateTime format, you need to specify the time zone. LocalDateTime does not contain any information about the time zone, so you would need to convert it to a specific time zone using the OffsetDateTime class.
Here's an example of how you can convert the number 1689561881 to LocalDateTime format in the UTC time zone:
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
public class Main {
public static void main(String[] args) {
long number = 1689561881;
// Convert the number to LocalDateTime in the UTC time zone
LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(number, 0, ZoneOffset.UTC);
System.out.println(localDateTime);
}
}
Output:
2023-11-17T14:44:41
Note: The number 1689561881 represents the number of seconds since the Unix epoch (January 1, 1970, 00:00:00 UTC)
原文地址: https://www.cveoy.top/t/topic/h7zz 著作权归作者所有。请勿转载和采集!