Period getYears() method in Java with Examples
The getYears() method of Period in Java is used to get the amount of years of this period whit which it is used.
Note: 15 months is not equal to 1 years and 3 months.
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.
public List getYears()
Parameters: This method does not accepts any parameter.
Returns: This method returns the amounts of years in this current period.
Below programs illustrate the above method: