Java Date Time Java Java API
java.time.LocalDate
public LocalDate minusDays(long daysToSubtract)
This method subtracts the specified amount from the days field, if necessary decrementing the month and year fields as well to ensure a valid result.
package com.logicbig.example.localdate;import java.time.LocalDate;import java.time.Month;public class MinusDaysExample { public static void main (String... args) { LocalDate d = LocalDate.of(2016, Month.DECEMBER, 12); LocalDate localDate = d.minusDays(300); System.out.println(localDate); }}
2016-02-16
package com.logicbig.example.localdate;import java.time.LocalDate;import java.time.Month;public class MinusDaysExample2 { public static void main (String... args) { LocalDate d = LocalDate.of(2016, Month.JANUARY, 1); LocalDate localDate = d.minusDays(1); System.out.println(localDate); }}
2015-12-31