Java Add Number of Days to Current LocalDate

Tags: Java LocalDate

In this Java tutorial, we learn how to add a number of days in to current LocalDate value in Java programming language.

How to add number of days to current LocalDate in Java

In the following Java code, we learn how to add a number of days into the current LocalDate value with these steps:

  • Instantiate current LocalDate value using the LocalDate.now() static method.
  • Using the LocalDate.plusDays(long daysToAdd) method to create a new LocalDate object with number of days added.

AddDaysToCurrentLocalDateExample.java

import java.time.LocalDate;

public class AddDaysToCurrentLocalDateExample {
    public static void main(String... args) {
        int numberOfDays = 10;

        // Add Number of Days to Current LocalDate
        LocalDate currentDate = LocalDate.now();
        LocalDate newLocalDate = currentDate.plusDays(numberOfDays);

        System.out.println("Number of days: " + numberOfDays);
        System.out.println("Current LocalDate: " + currentDate);
        System.out.println("New LocalDate: " + newLocalDate);
    }
}
The output as below.
Number of days: 10
Current LocalDate: 2022-09-06
New LocalDate: 2022-09-16

Happy Coding 😊

Java Add Number of Days to Current Date

Java Add Number of Days to Current LocalDateTime

Java Add Number of Days to Current OffsetDateTime

Java Add Number of Days to Current ZonedDateTime

How to Use TemporalAdjusters in Java

How to Sort a List of Date in Java