public long getDelay(Frequency delay, Date nominalTime, Date cutOffTime)
throws IvoryException {
ExpressionHelper evaluator = ExpressionHelper.get();
Date now = new Date();
Date lateTime = nominalTime;
long delayMilliSeconds = evaluator.evaluate(delay.toString(),
Long.class);
int factor = 1;
// TODO we can get rid of this using formula
while (lateTime.compareTo(now)<=0) {
lateTime = addTime(lateTime, (int) (factor * delayMilliSeconds));