Java Date Time Java Java API
java.time.LocalTime
public LocalTime minusHours(long hoursToSubtract)
Returns a copy of this LocalTime with the specified number of hours subtracted, adjusting other fields if necessary.
package com.logicbig.example.localtime;import java.time.LocalTime;public class MinusHoursExample { public static void main (String... args) { LocalTime d1 = LocalTime.of(12, 30, 50); LocalTime d2 = d1.minusHours(5); System.out.println(d2); d2 = d1.minusHours(-5); System.out.println(d2); }}
07:30:5017:30:50