Close

Java Date Time - OffsetTime.minusSeconds() Examples

Java Date Time Java Java API 


Class:

java.time.OffsetTime

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

Method:

public OffsetTime minusSeconds(long seconds)

Returns a copy of this OffsetTime with the specified number of seconds subtracted, adjusting other fields if necessary.


Examples


package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class MinusSecondsExample {

public static void main(String... args) {
OffsetTime t1 = OffsetTime.now();
System.out.println(t1);

OffsetTime t2 = t1.minusSeconds(35);
System.out.println(t2);

OffsetTime t3 = t1.minusSeconds(35000);
System.out.println(t3);
}
}

Output

16:13:51.672-05:00
16:13:16.672-05:00
06:30:31.672-05:00




package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class MinusSecondsExample2 {

public static void main(String... args) {
OffsetTime t1 = OffsetTime.now();
System.out.println(t1);

OffsetTime t2 = t1.minusSeconds(-35);
System.out.println(t2);

OffsetTime t3 = t1.minusSeconds(-35000);
System.out.println(t3);
}
}

Output

16:13:53.798-05:00
16:14:28.798-05:00
01:57:13.798-05:00




See Also