Java Date Time Java Java API
Class:
java.time.LocalDate
Method:
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.
Examples
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); } }
Output2016-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); } }
Output2015-12-31
|
|