- 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 - 時區 ID
- java.time - 時區偏移
- java.time 包列舉
- java.time - 月份
- java.time 有用資源
- java.time - 討論
java.time.LocalDate.until() 方法示例
描述
java.time.LocalDate.until(ChronoLocalDate endDateExclusive) 方法將此日期與其他日期之間的期限計算為一個期限。
宣告
以下是 java.time.LocalDate.until(ChronoLocalDate endDateExclusive) 方法的宣告。
public Period until(ChronoLocalDate endDateExclusive)
引數
endDateExclusive − 作為 endDateExclusive 的結束日期,可以採用任何時間順序,不得為 null。
返回值
此日期和結束日期之間的期限,不得為 null。
示例
以下示例展示了 java.time.LocalDate.until(ChronoLocalDate endDateExclusive) 方法的用法。
package com.tutorialspoint;
import java.time.LocalDate;
public class LocalDateDemo {
public static void main(String[] args) {
LocalDate date = LocalDate.parse("2017-01-03");
LocalDate date1 = LocalDate.now();
System.out.println(date.until(date1).getDays());
}
}
讓我們編譯並執行上述程式,這將產生以下結果 −
9
廣告