The Java se 8 API for for normalize()
reads:
This normalizes the years and months units, leaving the days unit unchanged. The months unit is adjusted to have an absolute value less than 11, with the years unit being adjusted to compensate. For example, a period of "1 Year and 15 months" will be normalized to "2 years and 3 months". The sign of the years and months units will be the same after normalization. For example, a period of "1 year and -25 months" will be normalized to "-1 year and -1 month".
public static void main(String[] args) {
Consumer<Period> nlz = d -> System.out.println(d.normalized());
nlz.accept(Period.of( 50, 10, -100)); // case 1
nlz.accept(Period.of(-50, 10, -100)); // case 2
}
/*
program output
--------------
P50Y10M-100D
P-49Y-2M-100D
*/
case 1: Absolute value of months unit is 10, remains unchanged.
case 2: Absolute value of months unit is 10, but it is changed to -2.