Close

Java Date Time - OffsetTime.minusHours() 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 minusHours(long hours)

Returns a copy of this OffsetTime with the specified number of hours subtracted.



Examples


package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class MinusHoursExample {

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

OffsetTime t2 = t.minusHours(5);
System.out.println(t2);

OffsetTime t3 = t.minusHours(500);
System.out.println(t3);
}
}

Output

16:14:04.350-05:00
11:14:04.350-05:00
20:14:04.350-05:00




package com.logicbig.example.offsettime;

import java.time.OffsetTime;

public class MinusHoursExample2 {

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

OffsetTime t2 = t.minusHours(-5);
System.out.println(t2);

OffsetTime t3 = t.minusHours(-500);
System.out.println(t3);
}
}

Output

16:14:06.448-05:00
21:14:06.448-05:00
12:14:06.448-05:00




See Also