Javatime-localdate-until
提供:Dev Guides
java.time.LocalDate.until()メソッドの例
説明
- java.time.LocalDate.until(ChronoLocalDate endDateExclusive)*メソッドは、この日付と別の日付の間の期間を期間として計算します。
宣言
以下は、* java.time.LocalDate.until(ChronoLocalDate endDateExclusive)*メソッドの宣言です。
public Period until(ChronoLocalDate endDateExclusive)
パラメーター
*endDateExclusive* -終了日、排他的、任意の年代順である場合があり、nullではありません。
戻り値
この日付と終了日の間の期間、null以外
例
次の例は、java.time.LocalDate.until(ChronoLocalDate endDateExclusive)メソッドの使用方法を示しています。
package com.finddevguides;
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