Duration ofNanos(long nanos)
creates a Duration representing a
number of nanoseconds.
The seconds and nanoseconds are extracted from the specified nanoseconds.
ofNanos
has the following syntax.
public static Duration ofNanos(long nanos)
The following example shows how to use ofNanos
.
import java.time.Duration; 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.