Date lastActionTime = coordJob.getLastActionTime();
if (lastActionTime != null) {
// d is the real last action time.
Calendar d = Calendar.getInstance(DateUtils.getTimeZone(coordJob.getTimeZone()));
d.setTime(getLastActionTime());
TimeUnit timeUnit = TimeUnit.valueOf(coordJob.getTimeUnitStr());
int lastActionNumber = coordJob.getLastActionNumber();
boolean hasChanged = false;
while (true) {
if (!newPauseTime.after(d.getTime())) {
deleteAction(lastActionNumber);
d.add(timeUnit.getCalendarUnit(), -Integer.valueOf(coordJob.getFrequency()));
lastActionNumber = lastActionNumber - 1;
hasChanged = true;
}
else {
break;
}
}
if (hasChanged == true) {
coordJob.setLastActionNumber(lastActionNumber);
d.add(timeUnit.getCalendarUnit(), Integer.valueOf(coordJob.getFrequency()));
Date d1 = d.getTime();
coordJob.setLastActionTime(d1);
coordJob.setNextMaterializedTime(d1);
coordJob.resetDoneMaterialization();
}