Period ofMonths(int months)
creates a Period
representing a number of months.
ofMonths
has the following syntax.
public static Period ofMonths(int months)
The following example shows how to use ofMonths
.
import java.time.Period; /*from w ww .j av a 2 s. c om*/ public class Main { public static void main(String[] args) { Period p = Period.ofMonths(12); System.out.println(p.toString()); } }
The code above generates the following result.