jmrozanec/cron-utils

Validation error while generate cron string using cronBuilder

Opened this issue · 1 comments

Hi Team,

I am trying to use the cronBuilder like this.

        public static String getCronExpression(DailyRecurrence dailyRecurrence) throws Exception {
		CronBuilder cronBuilder = CronBuilder.cron(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
		TimeDTO time = TimeDTO.getTimeDTO(dailyRecurrence.getTime());
		cronBuilder.withYear(always());
		cronBuilder.withDoM(always());
		cronBuilder.withDoW(always());
		cronBuilder.withHour(on(time.getHour()));
		cronBuilder.withMinute(on(time.getMinute()));
		Cron cron = cronBuilder.instance();
		log.debug("Cron Expression  generated for dailyRecurrence:{} expression:{}",dailyRecurrence,cron.asString());
		return cron.asString();
	}

Now Am I supposed to specify only the hour and minute and nothing else because no matter what I specify I am getting the validation error message. An I using it incorrectly or my expectation is incorrect from CronBuilder
Invalid cron expression: 1 13 * * *. Both, a day-of-week AND a day-of-month parameter, are not supported.
If its something that I should be fixing from your documentation sorry to raise an issue. But I was not able to find any documentation.

@yhinge, may we ask you for a PR replicating the issue? We will be grateful for it.