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,
- Add two numbers using Java Generics
- Convert Java List to Json String using Jackson
- Convert Java Object to JSON using Jackson Library
- Java SE JDBC: Insert with PreparedStatement Example
- [Program] How to read three different values using Scanner in Java
- Java JDBC Batch Update Example with PreparedStatement
- Java Stream flatmap() Examples
- Save Java Object as JSON file using Jackson Library
- Java get day of the week as an int using DayOfWeek
- Create Nested Directories using Java Code
- Java JDBC Delete a Record in Database Table using PreparedStatement
- List of jars required for Struts2 project
- Convert Java Object to XML using Jackson Library
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Java JDBC Get Id of the Inserted Record with AutoIncrement
- How to list all tables using Java JDBC
- Java Jackson ObjectMapper Class with Examples
- Fix: Maven - Failed to execute goal - Compilation failure - Source/Target option 5 is no longer supported. Use 7 or later
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files
- Formatting Double in Java [Examples]
- How to run Java Unit Test cases with Apache Maven?
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- [Fix] java: integer number too large compilation error
- [Java] Read a File with UTF-8 Encoding
- How to detect Operating System using Java code
More Posts:
- Changed AD user display name showing old name in SharePoint - SharePoint
- How to detect Operating System using Java code - Java
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files - Java
- SharePoint Designer 2010 - errors were found when compiling the workflow - SharePoint
- [Fatal Error] XML The markup in the document following the root element must be well-formed. - Java
- How to set background color for android layout pragmatically using java and through xml - Android
- Fix- Microsoft Word Pages Appear Black - Microsoft
- How to display Line Number in Eclipse IDE - Eclipse