
- java.time 包類
- java.time - 首頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - 時間點
- java.time - 日期
- java.time - 日期時間
- java.time - 時間
- java.time - 月日
- java.time - 偏移日期時間
- java.time - 偏移時間
- java.time - 週期
- java.time - 年
- java.time - 年月
- java.time - 區域性日期時間
- java.time - 區域識別符號
- java.time - 區域偏移量
- java.time 包列舉
- java.time - 月份
- java.time 有用的資源
- java.time - 討論
java.time.LocalDate.of() 方法示例
描述
java.time.LocalDate.of(int year, Month month, int dayOfMonth) 方法從年、月和日獲取 LocalDate 例項。
宣告
以下是 java.time.LocalDate.of(int year, Month month, int dayOfMonth) 方法的宣告。
public static LocalDate of(int year, Month month, int dayOfMonth)
引數
year - 表示的年,範圍從 MIN_YEAR 到 MAX_YEAR
month - 表示的年份中的月
dayOfMonth - 表示的月份中的日,範圍從 1 到 31
返回值
非 null 的本地日期。
示例
以下示例演示了 java.time.LocalDate.of(int year, Month month, int dayOfMonth) 方法的用法。
package com.tutorialspoint; import java.time.LocalDate; import java.time.Month; public class LocalDateDemo { public static void main(String[] args) { LocalDate date = LocalDate.of(2017,Month.FEBRUARY,3); System.out.println(date); } }
讓我們編譯並執行上述程式,這將會產生以下結果 -
2017-02-03
廣告