Created
February 14, 2013 08:58
-
-
Save sscarduzio/4951439 to your computer and use it in GitHub Desktop.
This Quartz simple job does not fire ever.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.quartz.CronScheduleBuilder.cronSchedule; | |
import static org.quartz.JobBuilder.newJob; | |
import static org.quartz.TriggerBuilder.newTrigger; | |
import java.util.TimeZone; | |
import org.quartz.CronTrigger; | |
import org.quartz.Job; | |
import org.quartz.JobDetail; | |
import org.quartz.JobExecutionContext; | |
import org.quartz.JobExecutionException; | |
import org.quartz.Scheduler; | |
import org.quartz.impl.StdSchedulerFactory; | |
class Printer implements Job{ | |
public Printer(){ | |
System.out.println("created printer"); | |
} | |
@Override | |
public void execute(JobExecutionContext context) | |
throws JobExecutionException { | |
System.out.println("hi" + context.getFireTime()); | |
} | |
public static void main(String[] args) throws Throwable { | |
System.out.println("Starting"); | |
Scheduler s = StdSchedulerFactory.getDefaultScheduler(); | |
JobDetail job = newJob(Printer.class).build(); | |
CronTrigger trigger = | |
newTrigger() | |
.withIdentity("a", "a") | |
.withSchedule(cronSchedule("0/5 * * * * ?").inTimeZone(TimeZone.getDefault())) | |
.forJob(job).build(); | |
s.scheduleJob(job, trigger); | |
System.out.println("should fire in: "+ (trigger.getNextFireTime().getTime() - System.currentTimeMillis()) + " ms"); | |
s.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment