- java.time 包類
- java.time - 主頁
- java.time - Clock
- java.time - Duration
- java.time - Instant
- 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.LocalDate.ofEpochDay() 方法示例
說明
java.time.LocalDate.ofEpochDay(long epochDay) 方法從曆元日計數中獲取 LocalDate 例項。
宣告
以下是 java.time.LocalDate.ofEpochDay(long epochDay) 方法的宣告。
public static LocalDate ofEpochDay(long epochDay)
引數
epochDay − 基於 1970-01-01 曆元轉換的歷元日。
返回值
本地日期,非空。
異常
DateTimeException − 如果曆元日超過支援的日期範圍。
示例
以下示例顯示如何使用 java.time.LocalDate.ofEpochDay(long epochDay) 方法。
package com.tutorialspoint;
import java.time.LocalDate;
public class LocalDateDemo {
public static void main(String[] args) {
LocalDate date = LocalDate.ofEpochDay(100);
System.out.println(date);
}
}
讓我們編譯並執行上述程式,它將產生以下結果 −
1970-04-11
廣告