TimeUtils { public static int daysEscapedOver(long referenceTime) { return Math.round(((System.currentTimeMillis() - referenceTime) / 1000f) / (ONE_DAY * 1.0f) - 0.5f); }  static String formatDateTimeZone(final long timestampMs); static String formatDateTime(final long timestampMs); static long convertDateTimeToUTCMillis(final String dateTime); static String formatDuration(final long startTime, final long endTime); static String formatPeriod(final ReadablePeriod period); static ReadablePeriod parsePeriodString(final String periodStr); static String createPeriodString(final ReadablePeriod period); static boolean timeEscapedOver(long referenceTime, int second); static int daysEscapedOver(long referenceTime);  }
@Test public void testDayEscapedOver() throws InterruptedException { long baseTime = System.currentTimeMillis(); long oneDayBefore = baseTime - 86399000; TimeUnit.SECONDS.sleep(3); Assert.assertEquals( TimeUtils.daysEscapedOver(baseTime), 0); Assert.assertEquals(TimeUtils.daysEscapedOver(oneDayBefore), 1); }