The plusDays() method of Period class in Java is used to add the days to this period. This method operates only on DAYS and does not affect other two YEAR, MONTH.
public Period plusDays(long daysToAdd)
Parameters: This method accepts a single parameter daysToAdd which is the number of days to be added from the period.
Return Value: It returns a Period based on provided period in the input adding the specified number of days. It must not be null.
Exceptions: It throws a ArithmeticException if numeric overflow occurs.
Below programs illustrate the above method:
Program 2: Period can be negative.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.