code: public static long round(final long time, final int precision, final TimeZone tz) {
          if ((precision == PRECISION_SECOND) && ((time % Dates.MILLIS_PER_SECOND) == 0)) {
              return time;
          }
          final Calendar cal = Calendar.getInstance(tz);
          cal.setTimeInMillis(time);
          if (precision == PRECISION_DAY) {
  //            return (long) Math.floor(time / (double) Dates.MILLIS_PER_DAY) * Dates.MILLIS_PER_DAY;
              cal.set(Calendar.HOUR_OF_DAY, 0);
              cal.clear(Calendar.MINUTE);
              cal.clear(Calendar.SECOND);
              cal.clear(Calendar.MILLISECOND);
          }
          else if (precision == PRECISION_SECOND) {
  //            return (long) Math.floor(time / (double) Dates.MILLIS_PER_SECOND) * Dates.MILLIS_PER_SECOND;
              cal.clear(Calendar.MILLISECOND);
          }
          // unrecognised precision..
          return cal.getTimeInMillis();
      }
docs: Rounds a time value to remove any precision smaller than specified.
  @param time the time value to round
  @param precision the rounding precision
  @param tz the timezone of the rounded value
  @return a round time value