Duration ofSeconds(long seconds, long nanoAdjustment) example

Description

Duration ofSeconds(long seconds, long nanoAdjustment) creates a Duration representing a number of seconds and an adjustment in nanoseconds.

Syntax

ofSeconds has the following syntax.


public static Duration ofSeconds(long seconds,   long nanoAdjustment)

Example

The following example shows how to use ofSeconds.


import java.time.Duration;
//from   w  ww  .j  ava 2s. c  o m
public class Main {
  public static void main(String[] args) {
    Duration duration = Duration.ofSeconds(10);
    System.out.println(duration);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset