Java Date Time Java Java API
java.time.Period
public static Period ofMonths(int months)
This method returns an instance of Period representing the provided number of months.
Period
package com.logicbig.example.period;import java.time.Period;public class OfMonthsExample { public static void main(String... args) { Period p = Period.ofMonths(2); System.out.println(p); Period p2 = Period.ofMonths(200); System.out.println(p2); Period p3 = Period.ofMonths(-200); System.out.println(p3); }}
P2MP200MP-200M