- 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 - 週期
- java.time - 年
- java.time - 年月
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time 包列舉
- java.time - 月
- java.time 有用資源
- java.time - 討論
java.time.Instant.ofEpochSecond() 方法示例
說明
java.time.Instant.ofEpochSecond(long epochSecond) 方法使用 1970-01-01T00:00:00Z 時間段的秒數獲取 Instant 例項。
宣告
下面是 java.time.Instant.ofEpochSecond(long epochSecond) 方法的宣告。
public static Instant ofEpochSecond(long epochSecond)
java.time.Instant java.time.Instant.ofEpochSecond(long epochSecond)
引數
epochSecond - 從 1970-01-01T00:00:00Z 起的秒數。
返回值
一個 instant,非空。
異常
DateTimeException - 如果 instant 超過最大或最小 instant。
示例
package com.tutorialspoint;
import java.time.Instant;
public class InstantDemo {
public static void main(String[] args) {
Instant instant = Instant.ofEpochSecond(10000);
System.out.println(instant);
}
}
線上演示
1970-01-01T02:46:40Z
列印頁面