Answers for "java 8 datediff in days"

0

java 8 datediff in days

LocalDate dateBefore;
LocalDate dateAfter;
long daysBetween = DAYS.between(dateBefore, dateAfter);
Posted by: Guest on November-25-2020
-1

java localdate subtract two dates

@Test
public void givenTwoDatesInJava8_whenDifferentiating_thenWeGetSix() {
    LocalDate now = LocalDate.now();
    LocalDate sixDaysBehind = now.minusDays(6);
 
    Period period = Period.between(now, sixDaysBehind);
    int diff = period.getDays();
 
    assertEquals(diff, 6);
}
Posted by: Guest on March-21-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language