public long next(long startTime,long fromTime,long currentCount){
  if (startTime == 0)   startTime=RecurrenceUtil.now();
  if (fromTime == 0)   fromTime=startTime;
  if (getEndTime() != 0 && getEndTime() <= RecurrenceUtil.now())   return 0;
  Debug.logVerbose("Rule NOT expired by end time.",module);
  if (getCount() != -1 && currentCount >= getCount())   return 0;
  Debug.logVerbose("Rule NOT expired by max count.",module);
  boolean isSeeking=true;
  long nextRuntime=0;
  long seekTime=fromTime;
  int loopProtection=0;
  int maxLoop=(10 * 10 * 10* 10* 10);
  while (isSeeking && loopProtection < maxLoop) {
    Date nextRun=getNextFreq(startTime,seekTime);
    seekTime=nextRun.getTime();
    if (validByRule(nextRun)) {
      isSeeking=false;
      nextRuntime=nextRun.getTime();
    }
    loopProtection++;
  }
  return nextRuntime;
}

public long next ( long startTime , long fromTime , long currentCount ) { if ( startTime == 0 ) startTime = RecurrenceUtil . now ( ) ; if ( fromTime == 0 ) fromTime = startTime ; if ( getEndTime ( ) != 0 && getEndTime ( ) <= RecurrenceUtil . now ( ) ) return 0 ; Debug . logVerbose ( "Rule NOT expired by end time." , module ) ; if ( getCount ( ) != - 1 && currentCount >= getCount ( ) ) return 0 ; Debug . logVerbose ( "Rule NOT expired by max count." , module ) ; boolean isSeeking = true ; long nextRuntime = 0 ; long seekTime = fromTime ; int loopProtection = 0 ; int maxLoop = ( 10 * 10 * 10 * 10 * 10 ) ; while ( isSeeking && loopProtection < maxLoop ) { Date nextRun = getNextFreq ( startTime , seekTime ) ; seekTime = nextRun . getTime ( ) ; if ( validByRule ( nextRun ) ) { isSeeking = false ; nextRuntime = nextRun . getTime ( ) ; } loopProtection ++ ; } return nextRuntime ; }
returns the next recurrence of this rule .
