![]() |
VOOZH | about |
The minusDays() method of the LocalDate class is used to subtract a specified number of days from a given date and return a new LocalDate instance. Since LocalDate is immutable, the original date object remains unchanged after the operation. DateTimeException is thrown if the resulting date exceeds the supported date range of LocalDate.
Example:
2023-01-05
Explanation:
public LocalDate minusDays(long daysToSubtract)
Subtracting a positive value using minusDays() results in a date that is earlier than the original LocalDate.
Before subtracting days: 2018-11-13 After subtracting days: 2018-10-27
Explanation:
Providing a negative value to minusDays() increases the date value, effectively moving it forward in time.
Before subtracting days: 2018-12-24 After subtracting days: 2019-01-08
Explanation: