TimestampRoundDownUtil { public static long roundDownTimeStampSeconds(long timestamp, int roundDownSec) throws IllegalStateException { return roundDownTimeStampSeconds(timestamp, roundDownSec, null); }  static long roundDownTimeStampSeconds(long timestamp,
      int roundDownSec); static long roundDownTimeStampSeconds(long timestamp, int roundDownSec, TimeZone timeZone); static long roundDownTimeStampMinutes(long timestamp,
      int roundDownMins); static long roundDownTimeStampMinutes(long timestamp, int roundDownMins, TimeZone timeZone); static long roundDownTimeStampHours(long timestamp,
      int roundDownHours); static long roundDownTimeStampHours(long timestamp, int roundDownHours, TimeZone timeZone);  }
@Test public void testRoundDownTimeStampSeconds() { Calendar cal = BASE_CALENDAR_WITH_DEFAULT_TIMEZONE; Calendar cal2 = createCalendar(2012, 5, 15, 15, 12, 0, 0, null); long timeToVerify = cal2.getTimeInMillis(); long ret = TimestampRoundDownUtil.roundDownTimeStampSeconds(cal.getTimeInMillis(), 60); System.out.println("Cal 1: " + cal.toString()); System.out.println("Cal 2: " + cal2.toString()); Assert.assertEquals(timeToVerify, ret); }
@Test public void testRoundDownTimeStampSecondsWithTimeZone() { Calendar cal = BASE_CALENDAR_WITH_CUSTOM_TIMEZONE; Calendar cal2 = createCalendar(2012, 5, 15, 15, 12, 0, 0, CUSTOM_TIMEZONE); long timeToVerify = cal2.getTimeInMillis(); long withoutTimeZone = TimestampRoundDownUtil.roundDownTimeStampSeconds( cal.getTimeInMillis(), 60); long withTimeZone = TimestampRoundDownUtil.roundDownTimeStampSeconds( cal.getTimeInMillis(), 60, CUSTOM_TIMEZONE); assertThat(withoutTimeZone, not(equalTo(timeToVerify))); Assert.assertEquals(withTimeZone, timeToVerify); }