目录

static Instant ofEpochSecond(long epochSecond, long nanoAdjustment)

描述 (Description)

java.time.Instant.ofEpochSecond(long epochSecond, long nanoAdjustment)方法使用1970-01-01T00:00:00Z的纪元和秒的纳秒分数来获得Instant的实例。

声明 (Declaration)

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

public static Instant ofEpochSecond(long epochSecond, long nanoAdjustment)

参数 (Parameters)

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

  • nanoAdjustment - 纳秒调整到秒数,正或负。

返回值 (Return Value)

瞬间,不是空的。

异常 (Exceptions)

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

  • ArithmeticException - 如果发生数字溢出。

例子 (Example)

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

package com.iowiki;
import java.time.Instant;
public class InstantDemo {
   public static void main(String[] args) {
      Instant instant = Instant.ofEpochSecond(10000,1000);
      System.out.println(instant);   
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

1970-01-01T02:46:40.000001Z
↑回到顶部↑
WIKI教程 @2018