Java Date Time Java Java API
java.time.LocalDateTime
public LocalDateTime plusSeconds(long seconds)
Returns a copy of this LocalDateTime with the specified number of seconds added.
package com.logicbig.example.localdatetime;import java.time.LocalDateTime;import java.time.Month;public class PlusSecondsExample { public static void main (String... args) { LocalDateTime d = LocalDateTime.of(2016, Month.APRIL, 1, 22, 20, 30, 500); LocalDateTime d2 = d.plusSeconds(100); System.out.println(d2); d2 = d.plusNanos(-100); System.out.println(d2); }}
2016-04-01T22:22:10.0000005002016-04-01T22:20:30.000000400