I have this code:
public static int getDaysBetween(Date dateA, Date dateB) {
return Days.daysBetween(
new DateTime(dateA),
new DateTime(dateB))
.getDays();
}
And this test case:
@Test
public void test() {
Date dateFrom = buildDate(10, Calendar.JANUARY, 2018);
Date dateTo = buildDate(1, Calendar.JANUARY, 2018);
assertEquals(DateUtils.getDaysBetween(dateFrom, dateTo), -9);
}
Test passes most of the times, but it fails randomly. Sometimes, getDaysBetween
returns -8
instead of -9
.
What's wrong? Is it any JodaTime bug?