Start New Discussion within our Software Development Community

I'm new in java. I need some help, guys.
How can I determine in Java next run time of cron-like job?

For example, if I have crontab entry without command, like
"*/15 * * * *", every 15 minutes
"5 */2 * * 1", every Monday at 00:05, 02:05, 04:05...

I need to determine in java, when is next run.

I've already tried jcrontab's CrontabParser class, but not found a way to determine time.

Any help appreciate.
Thanks in advance!

I've found how to solve this task!
Here is a code:

* Determine next fire time of job from cron entry!
* Quartz package home page:
* Cron entry format: Seconds | Minutes | Hours | Day of month | Month Day of week | Year
* Note: Year is optional!
import java.util.Calendar;
import java.util.Date;
import org.quartz.CronTrigger;

class test{
  public static void main(String[] args) throws Exception{
	Calendar cal = Calendar.getInstance();
	Date currTime = cal.getTime();
	CronTrigger tr = new CronTrigger();
	tr.setCronExpression("0 5 * ? * *");
	Date nextFireAt = tr.getFireTimeAfter(currTime);

	System.out.println("Current date&time: "+currTime);
	System.out.println("Next fire at: "+nextFireAt);

Current date&time: Tue Dec 07 12:30:54 UZT 2010
Next fire at: Tue Dec 07 13:05:00 UZT 2010

This question has already been answered. Start a new discussion instead.