Personal blog, IT related and misc other stuff.

Parsing Crontab Syntax With Java

I wrote a small piece of code I wanted to share: I wanted to parse/interpret crontab style syntax in java and found out that there is not a single simple way to do this available right now. So I wrote a very basic parser.

You are right – there was a bug in there and it had to do with the “month-handling”:
The problem was that when you called mayRunAt(Calendar cal) and set the month to december (=11) but wrote the cron line with, for example,
“1 7 * 12 1-5” (12 => december) it would not run.

I uploaded the new code – please let me know in case it doesn’t work for you.