WeeklyCronJobExpressionBuilder

public class WeeklyCronJobExpressionBuilder

Cron expression builder for jobs, which should be triggered on given day of week at given time.

Constructors

WeeklyCronJobExpressionBuilder

public WeeklyCronJobExpressionBuilder(DayOfWeek dayOfWeek)

Constructor.

Parameters:
  • dayOfWeek – the day of week at which job should be fired, not null

WeeklyCronJobExpressionBuilder

public WeeklyCronJobExpressionBuilder(int dayOfWeekNumber)

Constructor.

Parameters:
  • dayOfWeekNumber – the day of week at which job should be fired, must be in range from 1 to 7
Throws:
  • java.lang.IllegalArgumentException – when dayOfWeekNumber isn’t in range from 1 to 7

Methods

build

public String build()

Builds cron expression with “0 M H ? * D” pattern.

Returns:the cron expression as String ready to be used with SchedulableJob classes

withTime

public WeeklyCronJobExpressionBuilder withTime(Time time)

Sets time, at which built job should be fired.

Parameters:
  • time – the time at which job should be fired, not null
Returns:

the WeeklyCronJobExpressionBuilder ready to build cron expressions