Java Date Time - Year minus(TemporalAmount amountToSubtract) example








Year minus(TemporalAmount amountToSubtract) returns a copy of this year with the specified amount subtracted.

Syntax

minus has the following syntax.

public Year minus(TemporalAmount amountToSubtract)

Example

The following example shows how to use minus.

import java.time.Period;
import java.time.Year;
/*from w  w  w . java2s.co m*/
public class Main {
  public static void main(String[] args) {
    Year y = Year.of(2014);
    Year l = y.minus(Period.ofYears(12));
    System.out.println(l);

  }
}

The code above generates the following result.