Is there any java class to get Date from cron expression

后端 未结 5 1596
时光说笑
时光说笑 2021-01-04 05:46

I need to find out the first occurrence of Date and time represented by given cron expression. Is there any java class, utility code which can help in getting data object fr

5条回答
  •  长发绾君心
    2021-01-04 06:18

    If you're using Spring you could use:

    CronTrigger trigger = new CronTrigger(cron);
    TriggerContext context = new TriggerContext() {
    
    public Date lastScheduledExecutionTime() {
        return null;
    }
    
    public Date lastActualExecutionTime() {
        return null;
    }
    
    public Date lastCompletionTime() {
        return null;
    }
    };
    return trigger.nextExecutionTime(context);
    

提交回复
热议问题