如何从给定日期和给定时间编写触发器
谁能告诉我如何在 Quartz Scheduler 中编写一个触发器,该触发器从周三(17:23:12)开始一直运行到周日(20:00:00)。我不确定是否可以。的重复。
Can anybody please tell me how to write a trigger in Quartz Scheduler which starts at Wednesday (17:23:12) and runs till Sunday (20:00:00). I am not sure about no. of repeations.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您不确定重复的次数或时间时,很难说应该如何执行此操作。了解这一点将有助于决定使用哪种类型的触发器(例如 CronTrigger 与 SimpleTrigger)。
但是,无论触发器的类型如何,您都可以创建一个星期三 17:23:12 的日期,并将其设置为触发器的 startTime 属性,以及另一个星期日 20:00:00 的日期,并将其设置为触发器的 startTime 属性。结束时间属性。
然后,如果是 SimpleTrigger,您将设置 XXX 的重复间隔和“无限期”的重复计数。如果是 CronTrigger,您将设置一个 cron 表达式来表示您希望触发发生的一天中的时间。
It's hard to say how you should do this when you aren't sure about the number or timing of the repeats. Knowing that would help decide which type of trigger to use (e.g. CronTrigger vs. SimpleTrigger).
However, regardless of the type of trigger, you would create a Date that is Wednesday at 17:23:12 and set that as the trigger's startTime property, and another Date that is Sunday at 20:00:00 and set that as the trigger's endTime property.
Then if a SimpleTrigger, you would set a repeat interval of XXX and a repeat count of "indefinitely". If a CronTrigger you would set a cron expression that represents the time(s) of day that you want the firing to occur.