Search code examples
c#schedulingquartz.netcrontrigger

how to get the next scheduled trigger fire time in Quartz.net


This is my first Quartz.net project. I have done my basic homework and all my cron triggers fire correctly and life is good. However Iam having a hard time finding a property in the api doc. I know its there , just cannot find it. How do I get the exact time a trigger is scheduled to fire ? If I have a trigger say at 8:00 AM every day where in the trigger class is this 8:00 AM stored in ?

_quartzScheduler.ScheduleJob(job, trigger);
Program.Log.InfoFormat
 ("Job {0} will trigger next time at: {1}", job.FullName, trigger.WhatShouldIPutHere?);

So far I have tried

GetNextFireTimeUtc(), StartTimeUTC and return value of _quartzScheduler.ScheduleJob() shown above. Nothing else on http://quartznet.sourceforge.net/apidoc/topic645.html

The triggers fire at their scheduled times correctly. Just the cosmetics. thank you


Solution

  • As jhouse said ScheduleJob returns the next schedule. I am using Quartz.net 1.0.3. and everything works fine.

    Remember that Quartz.net uses UTC date/time format.

    I've used this cron expression: "0 0 8 1/1 * ? *".

    DateTime ft = sched.ScheduleJob(job, trigger);
    

    If I print ft.ToString("dd/MM/yyyy HH:mm") I get this 09/07/2011 07.00
    which is not right cause I've scheduled my trigger to fire every day at 8AM (I am in London).

    If I print ft.ToLocalTime().ToString("dd/MM/yyyy HH:mm") I get what I expect 09/07/2011 08.00