java.time.Duration.of() 方法示例


java.time.Duration.of() 方法示例

package com.codingdict;

import java.time.Duration;
import java.time.temporal.ChronoUnit;

public class DurationDemo {
   public static void main(String[] args) {

      Duration duration = Duration.of(5, ChronoUnit.SECONDS);
      System.out.println(duration.getSeconds());      
   }
}