Duration plusNanos(long nanosToAdd) example
Description
Duration plusNanos(long nanosToAdd)
returns a copy
of this duration with the specified duration in nanoseconds added.
Syntax
plusNanos
has the following syntax.
public Duration plusNanos(long nanosToAdd)
Example
The following example shows how to use plusNanos
.
import java.time.Duration;
import java.time.LocalTime;
// www . ja va2s. c om
public class Main {
public static void main(String[] args) {
Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON);
duration = duration.plusNanos(1000);
System.out.println(duration.getNano());
}
}
The code above generates the following result.