Duration isZero() example
Description
Duration isZero()
checks if this duration is zero length.
A Duration can be positive, zero or negative.
Syntax
isZero
has the following syntax.
public boolean isZero()
Example
The following example shows how to use isZero
.
import java.time.Duration;
import java.time.LocalTime;
/*ww w.ja v a 2 s . c om*/
public class Main {
public static void main(String[] args) {
Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON);
System.out.println(duration.isZero());
}
}
The code above generates the following result.