java.time.Instant.ofEpochSecond(long epochSecond)
方法使用1970-01-01T00:00:00Z
的纪元中的秒来获取Instant
的实例。
声明
以下是java.time.Instant.ofEpochSecond(long epochSecond)
方法的声明。
public static Instant ofEpochSecond(long epochSecond)
参数
epochSecond
- 1970-01-01T00:00:00Z
的秒数。
返回值
瞬间,不是null
。
异常
DateTimeException
- 如果瞬间超过最大或最小瞬间。
示例
以下示例显示了java.time.Instant.ofEpochSecond(long epochSecond)
方法的用法。
package com.yiibai;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.ofEpochSecond(10000);
System.out.println(instant);
}
}
编译并运行上面的程序,这将产生以下结果 -
1970-01-01T02:46:40Z