Java Date Time Java Java API
java.time.Period
public static Period of(int years, int months, int days)
This method creates a Period instance representing the provided number of years, months and days.
Period
package com.logicbig.example.period;import java.time.Period;public class OfExample { public static void main(String... args) { Period p = Period.of(100, 10, 20); System.out.println(p); }}
P100Y10M20D
package com.logicbig.example.period;import java.time.Period;public class OfExample2 { public static void main(String... args) { Period p = Period.of(100, 200, 200); System.out.println(p); }}
P100Y200M200D
package com.logicbig.example.period;import java.time.Period;public class OfExample3 { public static void main(String... args) { Period p = Period.of(-100, -10, -20); System.out.println(p); }}
P-100Y-10M-20D