Duration dividedBy(long divisor) example
Description
Duration dividedBy(long divisor)
returns a copy of
this duration divided by the specified value.
This instance is immutable and unaffected by this method call.
Syntax
dividedBy
has the following syntax.
public Duration dividedBy(long divisor)
Example
The following example shows how to use dividedBy
.
import java.time.Duration;
import java.time.LocalTime;
//from ww w . ja 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.dividedBy(2);
System.out.println(duration.getSeconds());
}
}
The code above generates the following result.