- java.time 包類
- java.time - 首頁
- java.time - 時鐘
- java.time - 時長
- java.time - instant
- 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 - 時區識別符號
- java.time - 時區偏移量
- java.time 包列舉
- java.time - 月份
- java.time 實用資源
- java.time - 討論
java.time.LocalDate.isBefore() 方法示例
描述
java.time.LocalDate.isBefore(ChronoLocalDate other) 方法檢查此日期是否在指定日期之前。
宣告
以下是 java.time.LocalDate.isBefore(ChronoLocalDate other) 方法的宣告。
public boolean isBefore(ChronoLocalDate other)
引數
other − 用於比較的其他日期,非空。
返回值
如果此日期在指定日期之前,則返回 true。
示例
以下示例顯示如何使用 java.time.LocalDate.isBefore(ChronoLocalDate other) 方法。
package com.tutorialspoint;
import java.time.LocalDate;
public class LocalDateDemo {
public static void main(String[] args) {
LocalDate date = LocalDate.parse("2017-02-03");
LocalDate date1 = LocalDate.parse("2017-03-03");
System.out.println(date1.isBefore(date));
}
}
讓我們編譯並執行以上程式,這將產生以下結果 −
false
廣告