Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Java reference

LocalDate.plusDays()

Returns a date the given number of days later. Related: minusDays(), plusWeeks(), plusMonths(), plusYears().

Available since: Java 8

Syntax

public LocalDate plusDays(long daysToAdd)

Parameters

ParameterTypeDescription
daysToAddlongHow many days to add; may be negative.

Return value

LocalDateA new date; the original does not change.

Examples

Crossing a month and a year boundary:

void main() {
    LocalDate date = LocalDate.of(2025, 12, 30);
    IO.println(date.plusDays(5));
    IO.println(date.minusDays(30));
    IO.println(date.plusWeeks(1));
}

Output:

2026-01-04
2025-11-30
2026-01-06

plusMonths() does not go past the end of a month:

void main() {
    LocalDate jan31 = LocalDate.of(2025, 1, 31);
    IO.println(jan31.plusMonths(1));
    IO.println(jan31.plusYears(1));
}

Output:

2025-02-28
2026-01-31

Notes

Store the result: date.plusDays(1); without an assignment changes nothing. If the day does not exist in the new month, the last day of the month is used.

See also

  • LocalDate.of() — Creates a date from a year, month and day.
  • Period — A calendar amount in years, months and days — for example, an age.
  • ChronoUnit.between() — Counts the whole units (days, months, hours) between two dates or moments.

Related recipes

In the tutorial

  • Dates and times — The java.time package — LocalDate, LocalTime, LocalDateTime, date arithmetic, Period, Duration, ChronoUnit, time zones and Instant.

Thanks for reading!

Donate to the site — we work hard for you.