Java Date Time Java Java API
java.time.OffsetTime
public OffsetTime minusHours(long hours)
Returns a copy of this OffsetTime with the specified number of hours subtracted.
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); }}
16:14:04.350-05:0011:14:04.350-05:0020: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); }}
16:14:06.448-05:0021:14:06.448-05:0012:14:06.448-05:00