Java Date Time Java Java API
java.time.Period
public boolean isZero()
This method checks if all three units of this period are zero.
package com.logicbig.example.period;import java.time.Period;public class IsZeroExample { public static void main(String... args) { Period p = Period.of(100, 10, 20); System.out.println(p); boolean b = p.isZero(); System.out.println(b); Period p2 = Period.ofYears(0); boolean b2 = p2.isZero(); System.out.println(b2); }}
P100Y10M20Dfalsetrue