I am looking for a parser that converts a cron expression like 45 17 7 6 * *
into Every year, on June 7th at 17:45 The parser should be adjustable to other languages. German for the first step.
Is there a library for a
See here for the usecase.
*/5 * * * * Execute a cron job every 5 minutes. 0 * * * * Execute a cron job every hour.
A concrete Trigger that is used to fire a JobDetail at given moments in time, defined with Unix 'cron-like' definitions. For those unfamiliar with "cron", this means being able to create a firing schedule such as: "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".
A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule. These fields, separated by white space, can contain any of the allowed values with various combinations of the allowed characters for that field.
cronTrigger.getExpressionSummary()
Example:
CronTrigger t = new CronTrigger();
t.setCronExpression("0 30 10-13 ? * WED,FRI");
System.out.println(""+t.getExpressionSummary());
Output:
seconds: 0
minutes: 30
hours: 10,11,12,13
daysOfMonth: ?
months: *
daysOfWeek: 4,6
lastdayOfWeek: false
nearestWeekday: false
NthDayOfWeek: 0
lastdayOfMonth: false
years: *
You may find cron-utils useful for this task, since provides human readable descriptions in various languages and does not require a fully fledged scheduler to provide them. Supports multiple cron formats. Below a code snippet from the docs:
//create a descriptor for a specific Locale
CronDescriptor descriptor = CronDescriptor.instance(Locale.UK);
//parse some expression and ask descriptor for description
String description = descriptor.describe(parser.parse("*/45 * * * * *"));
//description will be: "every 45 seconds"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With