Java Date Time - Duration from(TemporalAmount amount) example








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;

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.