Duration plus(Duration duration) example
Description
Duration plus(Duration duration)
returns a copy of
this duration with the specified duration added.
Syntax
plus
has the following syntax.
public Duration plus(Duration duration)
Example
The following example shows how to use plus
.
import java.time.Duration;
import java.time.LocalTime;
/*from ww w. j av a 2 s . 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.plus(duration);
System.out.println(duration.getSeconds());
}
}
The code above generates the following result.