- 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.LocalDate.ofYearDay() 方法示例
描述
java.time.LocalDate.ofYearDay(int year, int dayOfYear) 方法從一個年份和一個年中某天獲取 LocalDate 例項。
宣告
以下為 java.time.LocalDate.ofYearDay(int year, int dayOfYear) 方法的宣告。
public static LocalDate ofYearDay(int year, int dayOfYear)
public static LocalDate ofYearDay(int year, int dayOfYear)
引數
year - 將要表示的年份,從 MIN_YEAR 到 MAX_YEAR。
dayOfYear - 將要表示的年中某一天,從 1 到 366。
返回值
LocalDate,不為 null。
異常
DateTimeException - 如果任何欄位的值超出範圍,或者年中某天的日期對於該年份無效。
示例
package com.tutorialspoint;
import java.time.LocalDate;
public class LocalDateDemo {
public static void main(String[] args) {
LocalDate date = LocalDate.ofYearDay(2017,34);
System.out.println(date);
}
}
即時示例
2017-02-03
列印頁面
廣告