Java Date Time - LocalTime minus(long amountToSubtract, TemporalUnit unit) example








LocalTime minus(long amountToSubtract, TemporalUnit unit) returns a copy of this time with the specified amount subtracted.

Syntax

minus has the following syntax.

public LocalTime minus(long amountToSubtract,   TemporalUnit unit)

Example

The following example shows how to use minus.

import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
//  w w w .j  a  va  2 s  .  c o m
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.minus(1000,ChronoUnit.SECONDS);
    System.out.println(s);
  }
}

The code above generates the following result.