- java.time 包類
- java.time - 主頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - 即時
- java.time - LocalDate
- java.time - LocalDateTime
- java.time - LocalTime
- java.time - MonthDay
- java.time - OffsetDateTime
- java.time - OffsetTime
- java.time - Period
- java.time - Year
- java.time - YearMonth
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time 包列舉
- java.time - Month
- java.time 實用資源
- java.time - 討論
java.time.Instant.ofEpochMilli() 方法示例
描述
java.time.Instant.ofEpochMilli(long epochMilli) 方法獲取一個即時,它使用的是自 1970-01-01T00:00:00Z 以來的毫秒數。
宣告
以下是 java.time.Instant.ofEpochMilli(long epochMilli) 方法的宣告。
public static Instant ofEpochMilli(long epochMilli)
引數
epochMilli − 自 1970-01-01T00:00:00Z 以來的毫秒數。
返回值
即時,非空。
異常
DateTimeException − 如果即時超過最大或最小即時。
示例
以下示例顯示瞭如何使用 java.time.Instant.ofEpochMilli(long epochMilli) 方法。
package com.tutorialspoint;
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
廣告