You can add days/weeks/months/years to the Java Date Time API LocalDate class object using the below methods,
- plus(TemporalAmount amountToAdd): returns LocalDate
- plus(long amountToAdd, TemporalUnit unit): returns LocalDate
- plusDays(long daysToAdd): returns LocalDate
- plusWeeks(Long weeksToAdd): returns LocalDate
- plusMonths(long monthsToAdd): returns LocalDate
- plusYears(long yearsToAdd): returns LocalDate

Let's take a look at the code example,
package org.code2care;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
public class Java8AddDaysToDate {
public static void main(String[] args) {
LocalDate localDateToday = LocalDate.now();
System.out.println("Today: " + localDateToday);
//Adding one day to today
System.out.println("Today + 1 day = "+ localDateToday.plusDays(1));
//Adding one week to today
System.out.println("Today + 1 week = "+ localDateToday.plusWeeks(1));
//Adding one month to today
System.out.println("Today + 1 month = "+ localDateToday.plusMonths(1));
//Adding one year to today
System.out.println("Today + 1 year = "+ localDateToday.plusYears(1));
//Adding days/weeks/months/years using plus(long amountToAdd, TemporalUnit unit)
System.out.println("Today + 10 days = "+ localDateToday.plus(10, ChronoUnit.DAYS));
System.out.println("Today + 10 weeks = "+ localDateToday.plus(10, ChronoUnit.WEEKS));
System.out.println("Today + 10 months = "+ localDateToday.plus(10, ChronoUnit.MONTHS));
System.out.println("Today + 10 years = "+ localDateToday.plus(10, ChronoUnit.YEARS));
}
}
Output:
Today: 2022-05-14
Today + 1 day = 2022-05-15
Today + 1 week = 2022-05-21
Today + 1 month = 2022-06-14
Today + 1 year = 2023-05-14
Today + 10 days = 2022-05-24
Today + 10 weeks = 2022-07-23
Today + 10 months = 2023-03-14
Today + 10 years = 2032-05-14
More Posts related to Java,
- How to install Java 11 on Mac
- Get Client IP address from HTTP Response in Java
- SharePoint Open in the client application document opens in browser
- How to verify if java is installed on the computer and get version detail
- Java - Check if array contains the value
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- How to run Java Unit Test cases with Apache Maven?
- What Java version is used for Minecraft 1.18
- List of jar files for Jax-ws (SOAP) based Java Web Services
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- Convert Instant timestamp into LocalDateTime Java Code Example
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Create simple struts2 project using maven commands
- Java - PatternSyntaxException
- List of Online Java compiler with console
- Minecraft Java Edition
- How to declare and initialize Array in Java Programming
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- Java XML-RPC 3.1.x based web service example
- Simple Struts 2 Tutorial in eclipse with tomcat 7 server
- Java 8 foreach loop code examples
- Java -Day of the week using Java 8 DayOfWeek Enum
- Java 8 - Convert List to Map Examples
- Java: TimeZone List with GMT/UTC Offset
- list of jars required for hibernate 4.x.x
More Posts:
- MacBook - Time Limit - You have reached your time limit, Ignore Limit - MacOS
- How to install zsh shell on Ubuntu - Ubuntu
- Calculate days between dates using dateutils ddiff command - Linux
- Make div element draggable using jQuery - jQuery
- How to clear Mac Terminal screen - MacOS
- Minecraft Java Edition - Java
- Fix Microsoft Office 365 error code 135011 - Your organization has disabled this device - Microsoft
- Failed to find provider info for com.facebook.katana.provider.PlatformProvider - Android