- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to add Period to LocalDate
Let us first set a Period with month and days:
Period p = Period.ofMonths(5).plusDays(15);
Now set the LocalDate:
LocalDate date = LocalDate.of(2019, 4, 10);
Add period to LocalDate:
LocalDate res = date.plus(p);
Example
import java.time.LocalDate; import java.time.Period; public class Demo { public static void main(String[] args) { Period p = Period.ofMonths(5).plusDays(15); LocalDate date = LocalDate.of(2019, 4, 10); System.out.println("Date = "+date); LocalDate res = date.plus(p); System.out.println("Updated date = "+res); } }
Output
Date = 2019-04-10 Updated date = 2019-09-25
Advertisements