Close

Java Date Time - LocalTime.plusSeconds() Examples

Java Date Time Java Java API 


Class:

java.time.LocalTime

java.lang.Objectjava.lang.Objectjava.time.LocalTimejava.time.LocalTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public LocalTime plusSeconds(long secondsToAdd)

Returns a copy of this LocalTime with the specified number of seconds added.



Examples


package com.logicbig.example.localtime;

import java.time.LocalTime;

public class PlusSecondsExample {

public static void main (String... args) {
LocalTime t = LocalTime.of(10, 2, 20);

LocalTime t2 = t.plusSeconds(25);
System.out.println(t2);

t2 = t.plusSeconds(-25);
System.out.println(t2);

t2 = t.plusSeconds(500);
System.out.println(t2);
}
}

Output

10:02:45
10:01:55
10:10:40




See Also