Duration from(TemporalAmount amount) example

Description

Duration from(TemporalAmount amount) gets an instance of Duration from a temporal amount.

Syntax

from has the following syntax.


public static Duration from(TemporalAmount amount)

Example

The following example shows how to use from.


import java.time.Duration;
/*from   ww w . j  a v  a  2s. co  m*/
public class Main {
  public static void main(String[] args) {
    Duration duration = Duration.from(Duration.ZERO);
    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