plusDays() and minusDays()
Move a date forward or back by whole days, keep the result, and know how day arithmetic behaves around month ends and clock changes.
public LocalDate plusDays(long daysToAdd)
public LocalDate minusDays(long daysToSubtract)- Added in Java Java 8
Parameters
| Parameter | Type | Description |
|---|---|---|
$daysToAdd / daysToSubtract | long | The number of days to add or subtract; may be negative. |
Return value
LocalDateA new LocalDate with the days added or subtracted; the original is unchanged.
Errors
DateTimeException if the result exceeds the supported date range (years -999999999 to 999999999).
plusDays(n) and minusDays(n) return a new date n days later or earlier. They handle month lengths, leap years and year ends for you, so 2026-12-20 plus 14 days is 2027-01-03 without any special cases in your code. The same methods exist on LocalDateTime, ZonedDateTime and OffsetDateTime.
Keep the result
Every java.time type is immutable. due.plusDays(1); on its own line computes a new date and throws it away. This is the most common bug with these methods, and the compiler does not warn about it. Always assign: due = due.plusDays(1);.
Days are not months
"Due in 30 days" and "due in one month" are different rules. plusDays(30) counts days; plusMonths(1) moves the month and clamps the day, so 31 January plus one month is 28 February. Pick the one your business rule actually says, and write it into the method name so nobody swaps them later.
Days across a clock change
On a ZonedDateTime, plusDays(1) keeps the local wall-clock time: a 09:00 meeting the day before the clocks go forward is still at 09:00 the next day, even though only 23 hours passed. Adding Duration.ofDays(1) adds exactly 24 hours and lands at 10:00. Use plusDays for calendar rules (the same time tomorrow) and a Duration for elapsed time (a token valid for 24 hours).
Instant has no plusDays, because an instant has no calendar. Use instant.plus(1, ChronoUnit.DAYS), which means exactly 86,400 seconds.
Back-end uses
Due dates, trial expiry, retention windows ("delete logs older than 90 days" is today.minusDays(90) as a cut-off for a SQL WHERE clause), and reminder dates. Business-day rules are not built in: loop with plusDays(1) and skip weekends and holidays from your own calendar table.
Negative arguments work, so plusDays(-3) equals minusDays(3). Prefer the method whose name matches the meaning.
Example
When to use it
- Setting an invoice due date 14 days after the invoice date and a reminder three days before it.
- Computing a retention cut-off with today.minusDays(90) for a scheduled job that deletes old audit rows.
- Working out a dispatch date a number of business days ahead for an order confirmation email.
Frequently asked questions
How do I add days to a date in Java?
Call date.plusDays(n) and keep the result: LocalDate due = invoiced.plusDays(14). The original date does not change.
Why did plusDays not change my date?
java.time objects are immutable. plusDays returns a new LocalDate, so you must assign it, for example d = d.plusDays(1).
How do I add days to an Instant?
Instant has no plusDays. Use instant.plus(1, ChronoUnit.DAYS) or instant.plus(Duration.ofDays(1)), both exactly 24 hours. For calendar days in a zone, convert to ZonedDateTime first.
More examples
Thirty days is not one month
February 2026 has 28 days, so 30 days on from 31 January is 2 March, while plusMonths clamps to the last day of February. Choose the method that matches the written rule.
import java.time.*;
void main() {
LocalDate start = LocalDate.of(2026, 1, 31);
IO.println("plusDays(30): " + start.plusDays(30));
IO.println("plusMonths(1): " + start.plusMonths(1));
IO.println("plusWeeks(2): " + start.plusWeeks(2));
}
// Output:
// plusDays(30): 2026-03-02
// plusMonths(1): 2026-02-28
// plusWeeks(2): 2026-02-14Calendar day versus 24 hours across a clock change
UK clocks go forward on 29 March 2026. plusDays keeps 09:00 on the wall clock; adding a 24-hour Duration lands an hour later in local time.
import java.time.*;
void main() {
ZonedDateTime meeting = ZonedDateTime.of(2026, 3, 28, 9, 0, 0, 0, ZoneId.of("Europe/London"));
IO.println("plusDays(1): " + meeting.plusDays(1));
IO.println("plus(Duration 1 day): " + meeting.plus(Duration.ofDays(1)));
}
// Output:
// plusDays(1): 2026-03-29T09:00+01:00[Europe/London]
// plus(Duration 1 day): 2026-03-29T10:00+01:00[Europe/London]Adding business days
java.time has no business-day arithmetic, so step one day at a time and skip weekends. A real service would also skip dates from a holiday table.
import java.time.*;
LocalDate addBusinessDays(LocalDate start, int days) {
LocalDate d = start;
int added = 0;
while (added < days) {
d = d.plusDays(1);
DayOfWeek dow = d.getDayOfWeek();
if (dow != DayOfWeek.SATURDAY && dow != DayOfWeek.SUNDAY) {
added++;
}
}
return d;
}
void main() {
LocalDate friday = LocalDate.of(2026, 10, 16);
IO.println(friday + " " + friday.getDayOfWeek());
IO.println("+1 business day: " + addBusinessDays(friday, 1));
IO.println("+5 business days: " + addBusinessDays(friday, 5));
}
// Output:
// 2026-10-16 FRIDAY
// +1 business day: 2026-10-19
// +5 business days: 2026-10-23
Discussion