目录

long getEpochSecond()

描述 (Description)

java.time.Instant.getEpochSecond()方法获取1970-01-01T00:00:00Z的Java纪元的秒数​​。

声明 (Declaration)

以下是java.time.Instant.getEpochSecond()方法的声明。

public long getEpochSecond()

返回值 (Return Value)

1970-01-01T00:00:00Z时代的秒数。

例子 (Example)

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

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