long timeOut = 0; calendar.setTimeInMillis(timeIn); if (frequencyInDays()) { calendar.set(calendar.HOUR_OF_DAY, 0); } calendar.set(calendar.MINUTE, 0); calendar.set(calendar.SECOND, 0); calendar.set(calendar.MILLISECOND, 0); timeOut = calendar.getTimeInMillis();
long periods = (long) (timeIn/period);  long timeOut = periods * period;
  protected long getStartOfPeriod() {    long timeIn = getCurrentTimeMillis();    long timeOut = 0;    calendar.setTimeInMillis(timeIn);    if (frequencyInDays()) {      calendar.set(calendar.HOUR_OF_DAY, 0);    }    calendar.set(calendar.MINUTE, 0);    calendar.set(calendar.SECOND, 0);    calendar.set(calendar.MILLISECOND, 0);    timeOut = calendar.getTimeInMillis();    if (timeIn == timeOut) {      logger.error("GetStartOfToday - unexpected timeIn==timeOut==" + new Date(timeOut));    }    return timeOut;  }