The previous two is a simple trigger (Simpletrigger), Simpletrigger can only handle simple events, if you want to be flexible to trigger the task, you need to
Crontrigger this important person.
Crontrigger is also one of the most important features of quartz, by quartz specific cron expression to determine a certain kind of time, can complete similar "November 11, 2011 (God Stick Day, has passed), each Wednesday xxx" complex timing tasks.
Code or old routine, two classes: Simplejob.java and Crontriggerexample.java
It is recommended to run the code first, see the results, and then look at the code
Simplejob.java[Java] View plain copy import java.text.simpledateformat; import java.util.calendar; import org.quartz.job; import org.quartz.jobexecutioncontext; import org.quartz.jobexecutionexception; Public class simplejob implements Job { @Override public void execute (jobexecutioncontext context) throws JobExecutionException { // job 's name string jobname = context.getjobdetail (). GetKey (). GetName (); // Time of task execution simpledateformat dateformat = new simpledateformat ("yyyy year MM month dd Day HH time mm Division ss sec "); String jobRunTime = Dateformat.format (Calendar.getinstance (). GetTime ()); // Output Task performance system.out.println ("Task : " + jobName + " " +jobRunTime + " executed ");  } }
Crontriggerexample.java[Java] View Plain copy import static org.quartz.cronschedulebuilder.cronschedule; import static org.quartz.JobBuilder.newJob; import static org.quartz.triggerbuilder.newtrigger; import java.text.simpledateformat; import java.util.date; import org.quartz.crontrigger; Import org.quartz.JobDetail; import org.quartz.scheduler; import org.quartz.schedulerfactory; import org.quartz.schedulermetadata; import Use of org.quartz.impl.stdschedulerfactory; /** * Cron Triggers */ public class crontriggerexample { public static void main (String[] args) throws Exception { crontriggerexample example = new crontriggerexample (); example.run (); }