Period toTotalMonths() method in Java with Examples
The toTotalMonths() method of Period Class is used to obtain the total number of Months in the given period. It returns a long value depicting the same.
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 long toTotalMonths()
Parameters: This method does not accepts any parameter.
Returns: This function returns the long value which is the total number of Months in the this Period.
Below is the implementation of Period.toTotalMonths() method:
Period: P1Y2M21D Total number of Months in this Period: 14
Period: P-1Y-2M-21D Total number of Months in this Period: -14