The lengthOfMonth() method of YearMonth class in Java is used to return the length of month of this year-month object’s value in number of days. The value of length of month is in the range of 1 to 31. This method also take cares of leap years.
public int lengthOfMonth()
Parameter: This method does not accepts any parameter.
Return Value: It returns an integer value denoting the length of month in number of days.
Below programs illustrate the lengthOfMonth() method of YearMonth in Java:
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.