Java LocalDate isBefore() Method
Example
Check if one date comes before another:
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate date1 = LocalDate.of(2026, 1, 15);
LocalDate date2 = LocalDate.of(2026, 3, 1);
System.out.println(date1.isBefore(date2));
System.out.println(date2.isBefore(date1));
}
}
Definition and Usage
The isBefore() method checks if the date comes before another date.
It returns false if the two dates are the same.
Tip: Use the isAfter() method to check if a date comes after another date.
Syntax
public boolean isBefore(ChronoLocalDate other)
ChronoLocalDate is an interface that LocalDate implements, so you can pass a LocalDate.
Parameter Values
| Parameter | Description |
|---|---|
| other | Required. The date to compare with. |
Technical Details
| Returns: | true if the date comes before the other date, otherwise false. |
|---|
Related Pages
❮ Date and Time Methods