Java Duration class

Introduction

Java Duration class represents a date time span.

import java.time.Duration;

public class Main {
  public static void main(String[] args) {
    Duration d1 = Duration.ofSeconds(5);
    Duration d2 = Duration.ofSeconds(-7);
    System.out.println("d1:" + d1);
    System.out.println("d2:" + d2);

  }//  ww w  .j a v a 2s.  c  om
}



PreviousNext

Related