Package org.springframework.scheduling.config

# Class CronTask

java.lang.Object
org.springframework.scheduling.config.Task
org.springframework.scheduling.config.TriggerTask
org.springframework.scheduling.config.CronTask

public class CronTask extends TriggerTask
`TriggerTask` implementation defining a `Runnable` to be executed according to a standard cron expression.

Since:
  3.2
Author:
  Chris Beams
See Also:
  - `Scheduled.cron()`
  - `ScheduledTaskRegistrar.addCronTask(CronTask)`

## Constructor Summary

Constructors
Constructor
Description
`CronTask(Runnable runnable, String expression)`
Create a new `CronTask`.
`CronTask(Runnable runnable, CronTrigger cronTrigger)`
Create a new `CronTask`.

## Method Summary

Modifier and Type
Method
Description
`String`
`getExpression()`
Return the cron expression defining when the task should be executed.

### Methods inherited from class org.springframework.scheduling.config.TriggerTask

`getTrigger`

### Methods inherited from class org.springframework.scheduling.config.Task

`getLastExecutionOutcome, getRunnable, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### CronTask

public CronTask(Runnable runnable, String expression)
Create a new `CronTask`.

Parameters:
  `runnable` - the underlying task to execute
  `expression` - the cron expression defining when the task should be executed

### CronTask

public CronTask(Runnable runnable, CronTrigger cronTrigger)
Create a new `CronTask`.

Parameters:
  `runnable` - the underlying task to execute
  `cronTrigger` - the cron trigger defining when the task should be executed

## Method Details

### getExpression

public String getExpression()
Return the cron expression defining when the task should be executed.