java.time.Instant.getEpochSecond() 方法
描述
java.time.Instant.getEpochSecond() 方法获取 Java epoch 1970-01-01T00:00:00Z 的秒数。
声明
以下是 java.time.Instant.getEpochSecond() 方法的声明。
public long getEpochSecond()
返回值
从 1970-01-01T00:00:00Z 开始的秒数。
示例
下面的例子展示了 java.time.Instant.getEpochSecond() 方法的使用。
package com.tutorialspoint;
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

