Java Date Time Java Java API
java.time.Duration
public Temporal addTo(Temporal temporal)
This methods returns a temporal object of the same type as of the input temporal type, with this duration added.
package com.logicbig.example.duration;import java.time.Duration;import java.time.LocalTime;import java.time.temporal.ChronoUnit;import java.time.temporal.Temporal;public class AddToExample { public static void main(String... args) { Duration d = Duration.of(10, ChronoUnit.SECONDS); System.out.println(d); LocalTime t = LocalTime.now(); System.out.println(t); Temporal t2 = d.addTo(t); System.out.println(t2); }}
PT10S18:10:55.41418:11:05.414