- 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.YearMonth.adjustInto() 方法示例
描述
java.time.YearMonth.adjustInto(Temporal temporal) 方法將指定的時間物件調整為該年-月。
宣告
以下是 java.time.YearMonth.adjustInto(Temporal temporal) 方法的宣告。
public Temporal adjustInto(Temporal temporal)
引數
temporal - 要調整的時間物件(非空)。
返回值
已進行調整的相同型別的物件(非空)。
異常
DateTimeException - 如果無法新增。
ArithmeticException - 如果發生數字溢位。
示例
以下示例展示了 java.time.YearMonth.adjustInto(Temporal temporal) 方法的用法。
package com.tutorialspoint;
import java.time.LocalDate;
import java.time.YearMonth;
public class YearMonthDemo {
public static void main(String[] args) {
YearMonth year = YearMonth.of(2015,12);
LocalDate date = LocalDate.now();
System.out.println(date);
date = (LocalDate)year.adjustInto(date);
System.out.println(date);
}
}
讓我們編譯並執行上面的程式,它將會產生以下結果: -
2017-03-27 2015-12-27
廣告