Duration minusMillis(long millisToSubtract) example
Description
Duration minusMillis(long millisToSubtract)
returns a
copy of this duration with the specified duration in milliseconds subtracted.
Syntax
minusMillis
has the following syntax.
public Duration minusMillis(long millisToSubtract)
Example
The following example shows how to use minusMillis
.
import java.time.Duration;
import java.time.LocalTime;
//from ww w .j a va 2s . c o m
public class Main {
public static void main(String[] args) {
Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON);
System.out.println(duration.getSeconds());
duration = duration.minusMillis(300);
System.out.println(duration.getSeconds());
}
}
The code above generates the following result.