Java LocalDate minusDays() Method
Example
Subtract 20 days from a date:
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate myDate = LocalDate.of(2026, 1, 15);
System.out.println(myDate.minusDays(20));
}
}
Definition and Usage
The minusDays() method returns a new date, a number of days before the original date. The month and the year change when needed.
The original date is not changed.
Tip: Use the plusDays() method to go forward a number of days.
Syntax
public LocalDate minusDays(long daysToSubtract)
Parameter Values
| Parameter | Description |
|---|---|
| daysToSubtract | Required. The number of days to subtract. It can be negative. |
Technical Details
| Returns: | A new LocalDate object with the days subtracted. |
|---|
Related Pages
❮ Date and Time Methods