static Instant ofEpochMilli(long epochMilli)
描述 (Description)
java.time.Instant.ofEpochMilli(long epochMilli)方法使用1970-01-01T00:00:00Z的纪元中的毫秒来获取Instant的实例。
声明 (Declaration)
以下是java.time.Instant.ofEpochMilli(long epochMilli)方法的声明。
public static Instant ofEpochMilli(long epochMilli)
参数 (Parameters)
epochMilli - 从1970-01-01T00:00:00Z开始的毫秒数。
返回值 (Return Value)
瞬间,不是空的。
异常 (Exceptions)
DateTimeException - 如果瞬间超过最大或最小瞬间。
例子 (Example)
以下示例显示了java.time.Instant.ofEpochMilli(long epochMilli)方法的用法。
package com.iowiki;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.ofEpochMilli(10000);
System.out.println(instant);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
1970-01-01T00:00:10Z