Javatime-instant-getepochsecond
提供:Dev Guides
java.time.Instant.getEpochSecond()メソッドの例
説明
- java.time.Instant.getEpochSecond()*メソッドは、1970-01-01T00:00:00ZのJavaエポックから秒数を取得します。
宣言
以下は* java.time.Instant.getEpochSecond()*メソッドの宣言です。
public long getEpochSecond()
戻り値
1970-01-01T00:00:00Zのエポックからの秒。
例
次の例は、java.time.Instant.getEpochSecond()メソッドの使用法を示しています。
package com.finddevguides;
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