從即時值獲取瞬時秒的 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