Java Duration add two duration value

Description

Java Duration add two duration value

import java.time.Duration;

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

    Duration d1 = Duration.ofSeconds(100);
    Duration d2 = Duration.ofSeconds(100);

    // Add two durations
    Duration d3 = d1.plus(d2);//from  ww  w.j av  a2s.  co  m
    
    System.out.println(d1);
    System.out.println(d2);
    System.out.println(d3);
  }
}



PreviousNext

Related