
此功能不是标准cron表达式语法。因此,Spring可能永远不会实现它。看代码,我看不到任何
外科 解决方案的扩展
CronSequenceGenerator。那么,为什么不使用Quartz却是一个特殊功能呢?
根据您的确切需求,您可以实现自己的Trigger。就像是:
import java.util.Date;import org.joda.time.LocalDate;import org.joda.time.LocalTime;import org.springframework.scheduling.Trigger;import org.springframework.scheduling.TriggerContext;public class LastDayOfMonthTrigger implements Trigger { private final LocalTime time; public LastDayOfMonthTrigger(LocalTime time) { this.time = time; } @Override public Date nextExecutionTime(TriggerContext ctx) { Date last = ctx.lastScheduledExecutionTime(); LocalDate date = last == null ? new LocalDate() : new LocalDate(last).plusDays(1); LocalDate lastDay = date.dayOfMonth().withMaximumValue(); return lastDay.toDateTime(time).toDate(); }}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)