Java Date Time - ZonedDateTime minus(TemporalAmount amountToSubtract) example








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

Syntax

minus has the following syntax.

public ZonedDateTime minus(TemporalAmount amountToSubtract)

Example

The following example shows how to use minus.

import java.time.Period;
import java.time.ZonedDateTime;
//  ww  w. j  a v  a 2 s . com
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    ZonedDateTime n = dateTime.minus(Period.ofDays(12));
    System.out.println(n);
  } 
}

The code above generates the following result.