Year plusYears() Method in Java with Examples
plusYears() method of the Year class used to a copy of this Year after adding the specified number of years to this year.
This instance is immutable and unaffected by this method call.
public Year plusYears(long yearsToadd)
Parameters: This method accepts yearsToadd as parameter which is the years to add, may be negative.
Return value: This method returns Year based on this year with the years added.
Exception: This method throws following Exceptions:
- DateTimeException – if the result exceeds the supported range.
Below programs illustrate the plusYears() method:
Year :2019 After addition year: 2039
Year :2019 After addition year: 3219
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.