Duration ofNanos(long nanos) example
Description
Duration ofNanos(long nanos)
creates a Duration representing a
number of nanoseconds.
The seconds and nanoseconds are extracted from the specified nanoseconds.
Syntax
ofNanos
has the following syntax.
public static Duration ofNanos(long nanos)
Example
The following example shows how to use ofNanos
.
import java.time.Duration;
/*w ww.ja v a 2s .c o m*/
public class Main {
public static void main(String[] args) {
Duration duration = Duration.ofNanos(10);
System.out.println(duration);
}
}
The code above generates the following result.