java.time.Instant.getEpochSecond()
方法獲取1970-01-01T00:00:00Z
的Java紀元的秒數。
聲明
以下是java.time.Instant.getEpochSecond()
方法的聲明。
public long getEpochSecond()
返回值
1970-01-01T00:00:00Z
時代的秒數。
示例
以下示例顯示了java.time.Instant.getEpochSecond()
方法的用法。
package com.zaixian;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.parse("2017-03-03T10:37:30.00Z");
System.out.println(instant.getEpochSecond());
}
}
編譯並運行上面的程式,這將產生以下結果 -
1488537450
上一篇:
java.time.Instant類
下一篇:
java.time.LocalDate類