Duration is suitable when working with machine time and Instants. Durations can contain negative values if the end point occurs before the starting point.
Instant start= Instant.now();
Instant end= Instant.now();
Duration elapsed = Duration.between(start, end);
It has static method between which takes two instant of a timeline and give duration elapsed between these 2 instant on timelines. We have bunch of method in this class like toNanos(), toMillis(), toSeconds(), toMinutes(), toHours(), toDays(), minusNanons() – using minusNamnos() method, I can subtract nano seconds to given duration, plusNanos() – using plusNanos() method, I can add nano seconds to given duration using this method and mutipliedBy(), dividedBy(), negated(), isZero(), isNegative() etc.