Alex Rivera | Logout

Cron to human readable string

Asked 2009-08-05T20:23:22.370
19

I am using Quartz with Java to schedule jobs. One thing is that i store cron expressions on a database and i would like to present them to a user but in a more readable form. So i was wondering if there is a utility that could convert a cron expression into a human readable string. Something like :

""0 30 10-13 ? * WED,FRI" will become "Fires at 10:30, 11:30, 12:30, and 13:30, on every Wednesday and Friday."

Edit
Report

1 Answer

9

Well yes I did understand your question. But I should have explained my answer a little better.

No I don’t know any tool that will help you get a cron expression in “human” readable form. But by getting access to the CronExpression you can create you own.

Try calling

cronTrigger.getExpressionSummary() 

on the cron expression:

"0/2 * * 4 * ?"

it returns the following String:

seconds: 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58
minutes: *
hours: *
daysOfMonth: 4
months: *
daysOfWeek: ?
lastdayOfWeek: false
nearestWeekday: false
NthDayOfWeek: 0
lastdayOfMonth: false
calendardayOfWeek: false
calendardayOfMonth: false
years: *

By having access to the CronExpression object, you can create your own "human" explenation.

answered 2009-08-06T10:20:25.277

Your Answer