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.
dividedBy
has the following syntax.
public Duration dividedBy(long divisor)
The following example shows how to use dividedBy
.
import java.time.Duration; import java.time.LocalTime; //from w w w. j a va2 s . 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.dividedBy(2); System.out.println(duration.getSeconds()); } }
The code above generates the following result.