目录

static Instant ofEpochSecond(long epochSecond)

描述 (Description)

java.time.Instant.ofEpochSecond(long epochSecond)方法使用1970-01-01T00:00:00Z的纪元中的秒来获取Instant的实例。

声明 (Declaration)

以下是java.time.Instant.ofEpochSecond(long epochSecond)方法的声明。

public static Instant ofEpochSecond(long epochSecond)

参数 (Parameters)

epochSecond - 1970-01-01T00:00:00Z的秒数。

返回值 (Return Value)

瞬间,不是空的。

异常 (Exceptions)

DateTimeException - 如果瞬间超过最大或最小瞬间。

例子 (Example)

以下示例显示了java.time.Instant.ofEpochSecond(long epochSecond)方法的用法。

package com.iowiki;
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
↑回到顶部↑
WIKI教程 @2018