minusYears() method of the Year class used to a copy of this Year after subtracting the specified number of years from this year.
This instance is immutable and unaffected by this method call.
public Year minusYears(long yearsToSubtract)
Parameters: This method accepts yearsToSubtract as parameter which is the years to subtract, may be negative.
Return value: This method returns Year based on this year with the year subtracted.
Exception: This method throws following Exceptions:
- DateTimeException – if the result exceeds the supported range.
Below programs illustrate the minusYears() method:
Year :2019 After subtraction year: 1999
Year :2019 After subtraction year: 819
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.