YearMonth minusMonths(long monthsToSubtract)
returns a copy of this year-month with the specified period in months subtracted.
minusMonths
has the following syntax.
public YearMonth minusMonths(long monthsToSubtract)
The following example shows how to use minusMonths
.
import java.time.YearMonth; /* w w w. j a v a 2 s . c om*/ public class Main { public static void main(String[] args) { YearMonth y = YearMonth.now(); YearMonth s = y.minusMonths(12); System.out.println(s); } }
The code above generates the following result.