Java Date Time - LocalTime minusHours(long hoursToSubtract) example








LocalTime minusHours(long hoursToSubtract) returns a copy of this LocalTime with the specified period in hours subtracted.

Syntax

minusHours has the following syntax.

public LocalTime minusHours(long hoursToSubtract)

Example

The following example shows how to use minusHours.

import java.time.LocalTime;

public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.minusHours(1);
    System.out.println(s);
  }
}

The code above generates the following result.