This method returns the amount of years of this Period object.
package com.logicbig.example.period;
import java.time.Period;
public class GetYearsExample2 {
public static void main(String... args) {
Period p = Period.ofMonths(1000);
System.out.println(p);
int y = p.getYears();
System.out.println(y);
System.out.println("Normalizing");
Period p2 = p.normalized();
System.out.println(p2);
int y2 = p2.getYears();
System.out.println(y2);
}
}
Output
P1000M
0
Normalizing
P83Y4M
83