TimestampRoundDownUtil { public static long roundDownTimeStampMinutes(long timestamp, int roundDownMins) throws IllegalStateException { Preconditions.checkArgument(roundDownMins > 0 && roundDownMins <=60, "RoundDown must be > 0 and <=60"); Calendar cal = roundDownField(timestamp, Calendar.MINUTE, roundDownMins); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }  static long roundDownTimeStampSeconds(long timestamp,
      int roundDownSec); static long roundDownTimeStampMinutes(long timestamp,
      int roundDownMins); static long roundDownTimeStampHours(long timestamp,
      int roundDownHours);  }
@Test public void testRoundDownTimeStampMinutes() { Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(2012, 5, 15, 15, 12, 54); cal.set(Calendar.MILLISECOND, 20); Calendar cal2 = Calendar.getInstance(); cal2.clear(); cal2.set(2012, 5, 15, 15, 10, 0); cal2.set(Calendar.MILLISECOND, 0); long timeToVerify = cal2.getTimeInMillis(); long ret = TimestampRoundDownUtil. roundDownTimeStampMinutes(cal.getTimeInMillis(), 5); System.out.println("Cal 1: " + cal.toString()); System.out.println("Cal 2: " + cal2.toString()); Assert.assertEquals(timeToVerify, ret); }