Duration minusDays(long daysToSubtract)
returns a
copy of this duration with the specified duration in standard 24
hour days subtracted.
minusDays
has the following syntax.
public Duration minusDays(long daysToSubtract)
The following example shows how to use minusDays
.
import java.time.Duration; import java.time.LocalTime; /* w ww.j a v a2s . com*/ public class Main { public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON); System.out.println(duration.getSeconds()); duration = duration.minusDays(3); System.out.println(duration.getSeconds()); } }
The code above generates the following result.