Example usage for org.springframework.scheduling TriggerContext lastScheduledExecutionTime

List of usage examples for org.springframework.scheduling TriggerContext lastScheduledExecutionTime

Introduction

In this page you can find the example usage for org.springframework.scheduling TriggerContext lastScheduledExecutionTime.

Prototype

@Nullable
Date lastScheduledExecutionTime();

Source Link

Document

Return the last scheduled execution time of the task, or null if not scheduled before.

Usage

From source file:uk.ac.bbsrc.tgac.miso.notification.core.DynamicTrigger.java

/**
 * Returns the time after which a task should run again.
 *///from w w  w.ja v a2 s  . c  o m
public Date nextExecutionTime(TriggerContext triggerContext) {
    log.debug("lastScheduledExecutionTime::" + triggerContext.lastScheduledExecutionTime());
    if (triggerContext.lastScheduledExecutionTime() == null) {
        log.debug("nextExecutionTime::" + new Date(System.currentTimeMillis() + this.initialDelay));
        return new Date(System.currentTimeMillis() + this.initialDelay);
    } else if (this.fixedRate) {
        log.debug("nextExecutionTime::"
                + new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period));
        return new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period);
    }
    log.debug("nextExecutionTime::" + new Date(triggerContext.lastCompletionTime().getTime() + this.period));
    return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
}