java - Quartz Scheduler and NextFireTime -
i using quartz scheduler ,it's working fine. have following cron job:
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/jobschedulingdata" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.quartz-scheduler.org/xml/jobschedulingdata http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd" version="1.8"> <schedule> <job> <name>sendsmseveryminute</name> <group>everyminutegroup</group> <description>run job every minute</description> <job-class>com.sk.model.sendsmsmain</job-class> </job> <trigger> <cron> <name>dummytriggername</name> <job-name>sendsmseveryminute</job-name> <job-group>everyminutegroup</job-group> <!-- run every 1 minute --> <cron-expression>0 0/1 * * * ?</cron-expression> </cron> </trigger> </schedule> </job-scheduling-data>
now, have fired job every 1 minute starting now.(correct me if wrong.). well, want show jobs in quartz scheduler , code is:
public schedulerviewer() throws schedulerexception { servletcontext servletcontext = (servletcontext) facescontext .getcurrentinstance().getexternalcontext().getcontext(); //get quartzinitializerlistener stdschedulerfactory stdschedulerfactory = (stdschedulerfactory) servletcontext.getattribute(quartzinitializerlistener.quartz_factory_key); scheduler = stdschedulerfactory.getscheduler(); // loop jobs group (string groupname : scheduler.getjobgroupnames()) { // jobkey (jobkey jobkey : scheduler.getjobkeys(groupmatcher.jobgroupequals(groupname))) { string jobname = jobkey.getname(); string jobgroup = jobkey.getgroup(); // job's trigger list<trigger> triggers = (list<trigger>) scheduler.gettriggersofjob(jobkey); date date = triggers.get(0).getnextfiretime(); //converting joda time datetime datetime = date == null ? null : new datetime(triggers.get(0).getnextfiretime()); datetimezone tz = datetimezone.forid("asia/kathmandu"); system.out.println("tz:0--------->"+tz.getid()); quartzjoblist.add(new quartzjob(jobname, jobgroup, datetime.withzone(datetimezone.forid("asia/kathmandu")).todate())); } } }
well, works when view in web page see wrong or different next fire time. tried joda time convert local time. have missed?
**
i correct time printed in console though:info: date2013-08-20t07:10:00.000+05:45
**
okay here did finally. converted datetime string format , used in jfs view.
datetime datetime = date == null ? null : new datetime(triggers.get(0).getnextfiretime()); if (datetime != null) { quartzjoblist.add(new quartzjob(jobname, jobgroup, datetime.tostring("mm/dd/yyyy hh:mm:ss"))); }
Comments
Post a Comment