从即时值获取瞬时秒的 Java 程序
创建瞬时值并获取 1970-01-01T00:00:00Z 历元以来的时间,以毫秒为单位传入参数。这使用 ofEpochMilli() 完成
Instant instant = Instant.ofEpochMilli(342627282920l);
现在从瞬时值获取瞬时秒
instant.getEpochSecond();
示例
import java.time.Instant;
public class Demo {
public static void main(String[] args) {
Instant instant = Instant.ofEpochMilli(342627282920l);
long res = instant.getEpochSecond();
System.out.println(res);
}
}输出
342627282
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP