Period toTotalMonths()
gets the total number of months in this period.
toTotalMonths
has the following syntax.
public long toTotalMonths()
The following example shows how to use toTotalMonths
.
import java.time.Period; // w ww .j a v a 2 s .co m public class Main { public static void main(String[] args) { Period p = Period.ofMonths(1); long l = p.toTotalMonths(); System.out.println(l); } }
The code above generates the following result.