Java Date Time Java Java API
java.time.Duration
public boolean isNegative()
Checks if this duration is negative.
package com.logicbig.example.duration;import java.time.Duration;import java.time.LocalDate;import java.time.LocalDateTime;public class IsNegativeExample { public static void main(String... args) { Duration d = Duration.between(LocalDate.now().atStartOfDay(), LocalDateTime.now()); System.out.println(d); boolean b = d.isNegative(); System.out.println(b); d = Duration.between(LocalDateTime.now(), LocalDate.now().atStartOfDay()); System.out.println(d); b = d.isNegative(); System.out.println(b); }}
PT15H59M22.459SfalsePT-15H-59M-22.461Strue