private Date advanceToNextDayOfWeekIfNecessary(Date fireTime,boolean forceToAdvanceNextDay){
  TimeOfDay sTimeOfDay=getStartTimeOfDay();
  Date fireTimeStartDate=sTimeOfDay.getTimeOfDayForDate(fireTime);
  Calendar fireTimeStartDateCal=createCalendarTime(fireTimeStartDate);
  int dayOfWeekOfFireTime=fireTimeStartDateCal.get(Calendar.DAY_OF_WEEK);
  Set<Integer> daysOfWeekToFire=getDaysOfWeek();
  if (forceToAdvanceNextDay || !daysOfWeekToFire.contains(dayOfWeekOfFireTime)) {
    for (int i=1; i <= 7; i++) {
      fireTimeStartDateCal.add(Calendar.DATE,1);
      dayOfWeekOfFireTime=fireTimeStartDateCal.get(Calendar.DAY_OF_WEEK);
      if (daysOfWeekToFire.contains(dayOfWeekOfFireTime)) {
        fireTime=fireTimeStartDateCal.getTime();
        break;
      }
    }
  }
  Date eTime=getEndTime();
  if (eTime != null && fireTime.getTime() > eTime.getTime()) {
    return null;
  }
  return fireTime;
}

private Date advanceToNextDayOfWeekIfNecessary ( Date fireTime , boolean forceToAdvanceNextDay ) { TimeOfDay sTimeOfDay = getStartTimeOfDay ( ) ; Date fireTimeStartDate = sTimeOfDay . getTimeOfDayForDate ( fireTime ) ; Calendar fireTimeStartDateCal = createCalendarTime ( fireTimeStartDate ) ; int dayOfWeekOfFireTime = fireTimeStartDateCal . get ( Calendar . DAY_OF_WEEK ) ; Set < Integer > daysOfWeekToFire = getDaysOfWeek ( ) ; if ( forceToAdvanceNextDay || ! daysOfWeekToFire . contains ( dayOfWeekOfFireTime ) ) { for ( int i = 1 ; i <= 7 ; i ++ ) { fireTimeStartDateCal . add ( Calendar . DATE , 1 ) ; dayOfWeekOfFireTime = fireTimeStartDateCal . get ( Calendar . DAY_OF_WEEK ) ; if ( daysOfWeekToFire . contains ( dayOfWeekOfFireTime ) ) { fireTime = fireTimeStartDateCal . getTime ( ) ; break ; } } } Date eTime = getEndTime ( ) ; if ( eTime != null && fireTime . getTime ( ) > eTime . getTime ( ) ) { return null ; } return fireTime ; }
given firetime time determine if it is on a valid day of week . if so , simply return it unaltered , if not , advance to the next valid week day , and set the time of day to the start time of day
