2010-11-03 quartz学习笔记三(example3) CronTrigger

CronTriger 时间计划触发器




/**
* <p>
* Create a <code>CronTrigger</code> with fire time dictated by the
* <code>cronExpression</code> resolved with respect to the specified
* <code>timeZone</code> occurring from the <code>startTime</code> until
* the given <code>endTime</code>.
* </p>
*
* <p>
* If null, the start-time will also be set to the current time. If null,
* the time zone will be set to the system's default.
* </p>
*
* @param name
* of the <code>Trigger</code>
* @param group
* of the <code>Trigger</code>
* @param jobName
* name of the <code>{@link org.quartz.JobDetail}</code>
* executed on firetime
* @param jobGroup
* group of the <code>{@link org.quartz.JobDetail}</code>
* executed on firetime
* @param startTime
* A <code>Date</code> set to the earliest time for the <code>Trigger</code>
* to start firing.
* @param endTime
* A <code>Date</code> set to the time for the <code>Trigger</code>
* to quit repeat firing.
* @param cronExpression
* A cron expression dictating the firing sequence of the <code>Trigger</code>
* @param timeZone
* Specifies for which time zone the <code>cronExpression</code>
* should be interpreted, i.e. the expression 0 0 10 * * ?, is
* resolved to 10:00 am in this time zone.
* @throws ParseException
* if the <code>cronExpression</code> is invalid.
*/
public CronTrigger(String name, String group, String jobName,
String jobGroup, Date startTime, Date endTime,
String cronExpression, TimeZone timeZone) throws ParseException {
super(name, group, jobName, jobGroup);

setCronExpression(cronExpression);

if (startTime == null) {
startTime = new Date();
}
setStartTime(startTime);
if (endTime != null) {
setEndTime(endTime);
}
if (timeZone == null) {
setTimeZone(TimeZone.getDefault());
} else {
setTimeZone(timeZone);
}
}


Ps:此例子大量使用了
  sched.addJob(job, true);
,而trigger和Jobd的关联是通过trigger的构造方法里的jobName进行关联,和
sched.scheduleJob(job, trigger);
作用应该是一样的,只不过后者的关联关系更明显。
cronExpresstion,时间计划表达式,要用的时候可以谷歌,有详细的说明
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值