PeriodicJobTrigger implements JobTrigger { public Date getNextExecutionAfter(Date date) { if (endTime != -1 && date.getTime() >= endTime) return null; if (repeatCount != -1 && triggerCount >= repeatCount) return null; if (date.getTime() < startTime) return new Date(startTime); long nextExecution = 0; long triggerCount = (long) Math.floor((date.getTime() - startTime) / period); if (triggerCount == 0 && startImmediately && firstExecution) nextExecution = startTime; else nextExecution = startTime + (triggerCount + 1) * period; firstExecution = false; return new Date(nextExecution); } PeriodicJobTrigger(long period);  PeriodicJobTrigger(long period, boolean startImmediately);  PeriodicJobTrigger(long period, Date startTime);  PeriodicJobTrigger(long period, Date startTime,
      boolean startImmediately);  PeriodicJobTrigger(long period, Date startTime, Date endTime);  PeriodicJobTrigger(long period, Date startTime, Date endTime,
      boolean startImmediately);  PeriodicJobTrigger(long period, Date startTime, Date endTime,
      long repeat);  PeriodicJobTrigger(long period, Date startTime, Date endTime,
      long repeat, boolean startImmediately); @Override Object clone(); Date getNextExecutionAfter(Date date); void triggered(Date date); long getPeriod(); void setPeriod(long period); void setRepeatCount(long repeatCount); long getRepeatCount(); boolean getStartsImmediately(); void setStartImmediately(boolean startImmediately); void reset(); @Override String toString();  }
@Test public void testGetNextExecutionAfter() { assertEquals(startDate.getTime(), trigger.getNextExecutionAfter(now).getTime()); assertEquals(startDate.getTime() + period, trigger.getNextExecutionAfter(startDate).getTime()); assertTrue(trigger.getNextExecutionAfter(endDate) == null); }