Returns a copy of this year with the specified temporal amount subtracted.
Returns a copy of this year with the specified amount for the specified temporal unit subtracted.
package com.logicbig.example.year;
import java.time.Year;
import java.time.temporal.ChronoUnit;
import java.time.temporal.UnsupportedTemporalTypeException;
public class MinusExample2 {
public static void main(String... args) {
Year d = Year.now();
System.out.println(d);
for (ChronoUnit chronoUnit : ChronoUnit.values()) {
try {
Year d2 = d.minus(1, chronoUnit);
System.out.printf("%10s: %s%n", chronoUnit.name(), d2);
} catch (UnsupportedTemporalTypeException e) {
System.out.printf("%10s: not supported%n", chronoUnit.name());
}
}
}
}
Output
2017
NANOS: not supported
MICROS: not supported
MILLIS: not supported
SECONDS: not supported
MINUTES: not supported
HOURS: not supported
HALF_DAYS: not supported
DAYS: not supported
WEEKS: not supported
MONTHS: not supported
YEARS: 2016
DECADES: 2007
CENTURIES: 1917
MILLENNIA: 1017
ERAS: -2016
FOREVER: not supported