jmrozanec/cron-utils

Is there a chance to have CronMapper from QUARTZ to SPRING53 ?

unstoppable95 opened this issue · 4 comments

Hi guys,
I'd like to have a mapper from QUARTZ format to SPRING53 as I need to support additional L, # for days of the week and L,W day of the month. After creating my custom one and calling .map method I keep getting a problem that "value missing for a#b cron expresion" even it it's already there inside Cron when I call mapper.map() method (from is quartz definition and to is spring53 type inside CronMapper constuctor). Is there a chance to support this feature in upcoming weeks/months?

@unstoppable95 could you provide some PR with a test, to reproduce the issue?

just add new static method in CronMapper class:
public static CronMapper fromQuartzToSpring53() { return new CronMapper( CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ), CronDefinitionBuilder.instanceDefinitionFor(CronType.SPRING53), setQuestionMark() ); }

and then try to use in some test e.g:
@Test public void testRangeOfTimeQuartzToSpring53() { final String expected = "0 15 10 ? * 5#3"; final String expression = "0 15 10 ? * 6#3 1984"; assertEquals(expected, CronMapper.fromQuartzToSpring53().map(quartzParser().parse(expression)).asString()); }

and this results in "IllegalArgumentExpression....value missing for a#b cron expression" and main problem is in inside
at com.cronutils.model.field.expression.On.(On.java:43), not sure if this precondition check there is correct.

Regards & sorry for not creating PR, I did not have git installed on this PC and can't to this without local admin role...