Javatime-instant-ofepochmilli
提供:Dev Guides
java.time.Instant.ofEpochMilli()メソッドの例
説明
- java.time.Instant.ofEpochMilli(long epochMilli)*メソッドは、1970-01-01T00:00:00Zのエポックからのミリ秒を使用してInstantのインスタンスを取得します。
宣言
以下は* java.time.Instant.ofEpochMilli(long epochMilli)*メソッドの宣言です。
public static Instant ofEpochMilli(long epochMilli)
パラメーター
*epochMilli* -1970-01-01T00:00:00Zからのミリ秒数。
戻り値
インスタント、nullではない。
例外
*DateTimeException* -インスタントが最大または最小インスタントを超える場合。
例
次の例は、java.time.Instant.ofEpochMilli(long epochMilli)メソッドの使用方法を示しています。
package com.finddevguides;
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