Java Date Time - LocalDateTime minus(TemporalAmount amountToSubtract) example








LocalDateTime minus(TemporalAmount amountToSubtract) returns a copy of this date-time with the specified amount subtracted.

Syntax

minus has the following syntax.

public LocalDateTime minus(TemporalAmount amountToSubtract)

Example

The following example shows how to use minus.

import java.time.LocalDateTime;
import java.time.Period;
//from w  ww .  j a v  a  2  s  .co  m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    
    LocalDateTime t = a.minus(Period.ofDays(100));
    
    System.out.println(t);
  }
}

The code above generates the following result.