Java 程式從 Instant 獲取毫秒
建立一個 Instant,並使用 1970-01-01T00:00:00Z 以紀元作為引數傳遞的毫秒來獲取 Instant。這是透過 ofEpochMilli() 完成的
Instant instant = Instant.ofEpochMilli(342627282920l);
現在,從 Instant 獲取紀元毫秒
instant. toEpochMilli();
示例
import java.time.Instant;
public class Demo {
public static void main(String[] args) {
Instant instant = Instant.ofEpochMilli(1262347200000l);
long res = instant.toEpochMilli();
System.out.println(res);
}
}輸出
1262347200000
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP