C# Class Quartz.DateBuilder

DateBuilder is used to conveniently create java.util.Date instances that meet particular criteria.

Quartz provides a builder-style API for constructing scheduling-related entities via a Domain-Specific Language (DSL). The DSL can best be utilized through the usage of static imports of the methods on the classes TriggerBuilder, JobBuilder, DateBuilder, JobKey, TriggerKey and the various ScheduleBuilder implementations.

Client code can then use the DSL to write code such as this:

 JobDetail job = newJob(MyJob.class) .withIdentity("myJob") .build(); Trigger trigger = newTrigger() .withIdentity(triggerKey("myTrigger", "myTriggerGroup")) .withSchedule(simpleSchedule() .withIntervalInHours(1) .repeatForever()) .startAt(futureDate(10, MINUTES)) .build(); scheduler.scheduleJob(job, trigger); 
Afficher le fichier Open project: quartznet/quartznet Class Usage Examples

Méthodes publiques

Méthode Description
AtHourMinuteAndSecond ( int hour, int minute, int second ) : DateBuilder
AtHourOfDay ( int hour ) : DateBuilder

Set the hour (0-23) for the Date that will be built by this builder.

AtMinute ( int minute ) : DateBuilder

Set the minute (0-59) for the Date that will be built by this builder.

AtSecond ( int second ) : DateBuilder

Set the second (0-59) for the Date that will be built by this builder, and truncate the milliseconds to 000.

Build ( ) : DateTimeOffset

Build the DateTimeOffset defined by this builder instance.

DateOf ( int hour, int minute, int second ) : DateTimeOffset

Get a DateTimeOffset object that represents the given time, on today's date.

DateOf ( int hour, int minute, int second, int dayOfMonth, int month ) : DateTimeOffset

Get a DateTimeOffset object that represents the given time, on the given date.

DateOf ( int hour, int minute, int second, int dayOfMonth, int month, int year ) : DateTimeOffset

Get a DateTimeOffset object that represents the given time, on the given date.

EvenHourDate ( DateTimeOffset date ) : DateTimeOffset

Returns a date that is rounded to the next even hour above the given date.

For example an input date with a time of 08:13:54 would result in a date with the time of 09:00:00. If the date's time is in the 23rd hour, the date's 'day' will be promoted, and the time will be set to 00:00:00.

EvenHourDateAfterNow ( ) : DateTimeOffset

Returns a date that is rounded to the next even hour after the current time.

For example a current time of 08:13:54 would result in a date with the time of 09:00:00. If the date's time is in the 23rd hour, the date's 'day' will be promoted, and the time will be set to 00:00:00.

EvenHourDateBefore ( DateTimeOffset date ) : DateTimeOffset

Returns a date that is rounded to the previous even hour below the given date.

For example an input date with a time of 08:13:54 would result in a date with the time of 08:00:00.

EvenMinuteDate ( DateTimeOffset date ) : DateTimeOffset

Returns a date that is rounded to the next even minute above the given date.

For example an input date with a time of 08:13:54 would result in a date with the time of 08:14:00. If the date's time is in the 59th minute, then the hour (and possibly the day) will be promoted.

EvenMinuteDateAfterNow ( ) : DateTimeOffset

Returns a date that is rounded to the next even minute after the current time.

For example a current time of 08:13:54 would result in a date with the time of 08:14:00. If the date's time is in the 59th minute, then the hour (and possibly the day) will be promoted.

EvenMinuteDateBefore ( DateTimeOffset date ) : DateTimeOffset

Returns a date that is rounded to the previous even minute below the given date.

For example an input date with a time of 08:13:54 would result in a date with the time of 08:13:00.

EvenSecondDate ( DateTimeOffset date ) : DateTimeOffset

Returns a date that is rounded to the next even second above the given date.

EvenSecondDateAfterNow ( ) : DateTimeOffset

Returns a date that is rounded to the next even second after the current time.

EvenSecondDateBefore ( DateTimeOffset date ) : DateTimeOffset

Returns a date that is rounded to the previous even second below the given date.

For example an input date with a time of 08:13:54.341 would result in a date with the time of 08:13:00.000.

FutureDate ( int interval, IntervalUnit unit ) : DateTimeOffset
InMonth ( int month ) : DateBuilder

Set the month (1-12) for the Date that will be built by this builder.

InMonthOnDay ( int month, int day ) : DateBuilder
InTimeZone ( TimeZoneInfo tz ) : DateBuilder

Set the TimeZoneInfo for the Date that will be built by this builder (if "null", system default will be used)

InYear ( int year ) : DateBuilder

Set the year for the Date that will be built by this builder.

NewDate ( ) : DateBuilder

Create a DateBuilder, with initial settings for the current date and time in the system default timezone.

NewDateInTimeZone ( TimeZoneInfo tz ) : DateBuilder

Create a DateBuilder, with initial settings for the current date and time in the given timezone.

NextGivenMinuteDate ( DateTimeOffset date, int minuteBase ) : DateTimeOffset

Returns a date that is rounded to the next even multiple of the given minute.

For example an input date with a time of 08:13:54, and an input minute-base of 5 would result in a date with the time of 08:15:00. The same input date with an input minute-base of 10 would result in a date with the time of 08:20:00. But a date with the time 08:53:31 and an input minute-base of 45 would result in 09:00:00, because the even-hour is the next 'base' for 45-minute intervals.

More examples:

Input Time Minute-Base Result Time
11:16:41 20 11:20:00
11:36:41 20 11:40:00
11:46:41 20 12:00:00
11:26:41 30 11:30:00
11:36:41 30 12:00:00
11:16:41 17 11:17:00
11:17:41 17 11:34:00
11:52:41 17 12:00:00
11:52:41 5 11:55:00
11:57:41 5 12:00:00
11:17:41 0 12:00:00
11:17:41 1 11:08:00

NextGivenSecondDate ( DateTimeOffset date, int secondBase ) : DateTimeOffset

Returns a date that is rounded to the next even multiple of the given minute.

The rules for calculating the second are the same as those for calculating the minute in the method NextGivenMinuteDate.

OnDay ( int day ) : DateBuilder

Set the day of month (1-31) for the Date that will be built by this builder.

TodayAt ( int hour, int minute, int second ) : DateTimeOffset

Get a DateTimeOffset object that represents the given time, on today's date (equivalent to DateOf(int,int,int)).

TomorrowAt ( int hour, int minute, int second ) : DateTimeOffset

Get a DateTimeOffset object that represents the given time, on tomorrow's date.

ValidateDayOfMonth ( int day ) : void
ValidateHour ( int hour ) : void
ValidateMinute ( int minute ) : void
ValidateMonth ( int month ) : void
ValidateSecond ( int second ) : void
ValidateYear ( int year ) : void

Private Methods

Méthode Description
DateBuilder ( ) : System

Create a DateBuilder, with initial settings for the current date and time in the system default timezone.

DateBuilder ( TimeZoneInfo tz ) : System

Create a DateBuilder, with initial settings for the current date and time in the given timezone.

TranslatedAdd ( DateTimeOffset date, IntervalUnit unit, int amountToAdd ) : DateTimeOffset

Method Details

AtHourMinuteAndSecond() public méthode

public AtHourMinuteAndSecond ( int hour, int minute, int second ) : DateBuilder
hour int
minute int
second int
Résultat DateBuilder

AtHourOfDay() public méthode

Set the hour (0-23) for the Date that will be built by this builder.
public AtHourOfDay ( int hour ) : DateBuilder
hour int
Résultat DateBuilder

AtMinute() public méthode

Set the minute (0-59) for the Date that will be built by this builder.
public AtMinute ( int minute ) : DateBuilder
minute int
Résultat DateBuilder

AtSecond() public méthode

Set the second (0-59) for the Date that will be built by this builder, and truncate the milliseconds to 000.
public AtSecond ( int second ) : DateBuilder
second int
Résultat DateBuilder

Build() public méthode

Build the DateTimeOffset defined by this builder instance.
public Build ( ) : DateTimeOffset
Résultat DateTimeOffset

DateOf() public static méthode

Get a DateTimeOffset object that represents the given time, on today's date.
public static DateOf ( int hour, int minute, int second ) : DateTimeOffset
hour int The value (0-23) to give the hours field of the date
minute int The value (0-59) to give the minutes field of the date
second int The value (0-59) to give the seconds field of the date
Résultat DateTimeOffset

DateOf() public static méthode

Get a DateTimeOffset object that represents the given time, on the given date.
public static DateOf ( int hour, int minute, int second, int dayOfMonth, int month ) : DateTimeOffset
hour int The value (0-23) to give the hours field of the date
minute int The value (0-59) to give the minutes field of the date
second int The value (0-59) to give the seconds field of the date
dayOfMonth int The value (1-31) to give the day of month field of the date
month int The value (1-12) to give the month field of the date
Résultat DateTimeOffset

DateOf() public static méthode

Get a DateTimeOffset object that represents the given time, on the given date.
public static DateOf ( int hour, int minute, int second, int dayOfMonth, int month, int year ) : DateTimeOffset
hour int The value (0-23) to give the hours field of the date
minute int The value (0-59) to give the minutes field of the date
second int The value (0-59) to give the seconds field of the date
dayOfMonth int The value (1-31) to give the day of month field of the date
month int The value (1-12) to give the month field of the date
year int The value (1970-2099) to give the year field of the date
Résultat DateTimeOffset

EvenHourDate() public static méthode

Returns a date that is rounded to the next even hour above the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 09:00:00. If the date's time is in the 23rd hour, the date's 'day' will be promoted, and the time will be set to 00:00:00.
public static EvenHourDate ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset the Date to round, if the current time will /// be used
Résultat DateTimeOffset

EvenHourDateAfterNow() public static méthode

Returns a date that is rounded to the next even hour after the current time.
For example a current time of 08:13:54 would result in a date with the time of 09:00:00. If the date's time is in the 23rd hour, the date's 'day' will be promoted, and the time will be set to 00:00:00.
public static EvenHourDateAfterNow ( ) : DateTimeOffset
Résultat DateTimeOffset

EvenHourDateBefore() public static méthode

Returns a date that is rounded to the previous even hour below the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 08:00:00.
public static EvenHourDateBefore ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset the Date to round, if the current time will /// be used
Résultat DateTimeOffset

EvenMinuteDate() public static méthode

Returns a date that is rounded to the next even minute above the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 08:14:00. If the date's time is in the 59th minute, then the hour (and possibly the day) will be promoted.
public static EvenMinuteDate ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset The Date to round, if the current time will be used
Résultat DateTimeOffset

EvenMinuteDateAfterNow() public static méthode

Returns a date that is rounded to the next even minute after the current time.

For example a current time of 08:13:54 would result in a date with the time of 08:14:00. If the date's time is in the 59th minute, then the hour (and possibly the day) will be promoted.
public static EvenMinuteDateAfterNow ( ) : DateTimeOffset
Résultat DateTimeOffset

EvenMinuteDateBefore() public static méthode

Returns a date that is rounded to the previous even minute below the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 08:13:00.
public static EvenMinuteDateBefore ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset the Date to round, if the current time will /// be used
Résultat DateTimeOffset

EvenSecondDate() public static méthode

Returns a date that is rounded to the next even second above the given date.
public static EvenSecondDate ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset
Résultat DateTimeOffset

EvenSecondDateAfterNow() public static méthode

Returns a date that is rounded to the next even second after the current time.
public static EvenSecondDateAfterNow ( ) : DateTimeOffset
Résultat DateTimeOffset

EvenSecondDateBefore() public static méthode

Returns a date that is rounded to the previous even second below the given date.

For example an input date with a time of 08:13:54.341 would result in a date with the time of 08:13:00.000.

public static EvenSecondDateBefore ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset
Résultat DateTimeOffset

FutureDate() public static méthode

public static FutureDate ( int interval, IntervalUnit unit ) : DateTimeOffset
interval int
unit IntervalUnit
Résultat DateTimeOffset

InMonth() public méthode

Set the month (1-12) for the Date that will be built by this builder.
public InMonth ( int month ) : DateBuilder
month int
Résultat DateBuilder

InMonthOnDay() public méthode

public InMonthOnDay ( int month, int day ) : DateBuilder
month int
day int
Résultat DateBuilder

InTimeZone() public méthode

Set the TimeZoneInfo for the Date that will be built by this builder (if "null", system default will be used)
public InTimeZone ( TimeZoneInfo tz ) : DateBuilder
tz System.TimeZoneInfo
Résultat DateBuilder

InYear() public méthode

Set the year for the Date that will be built by this builder.
public InYear ( int year ) : DateBuilder
year int
Résultat DateBuilder

NewDate() public static méthode

Create a DateBuilder, with initial settings for the current date and time in the system default timezone.
public static NewDate ( ) : DateBuilder
Résultat DateBuilder

NewDateInTimeZone() public static méthode

Create a DateBuilder, with initial settings for the current date and time in the given timezone.
public static NewDateInTimeZone ( TimeZoneInfo tz ) : DateBuilder
tz System.TimeZoneInfo Time zone to use.
Résultat DateBuilder

NextGivenMinuteDate() public static méthode

Returns a date that is rounded to the next even multiple of the given minute.

For example an input date with a time of 08:13:54, and an input minute-base of 5 would result in a date with the time of 08:15:00. The same input date with an input minute-base of 10 would result in a date with the time of 08:20:00. But a date with the time 08:53:31 and an input minute-base of 45 would result in 09:00:00, because the even-hour is the next 'base' for 45-minute intervals.

More examples:

Input Time Minute-Base Result Time
11:16:41 20 11:20:00
11:36:41 20 11:40:00
11:46:41 20 12:00:00
11:26:41 30 11:30:00
11:36:41 30 12:00:00
11:16:41 17 11:17:00
11:17:41 17 11:34:00
11:52:41 17 12:00:00
11:52:41 5 11:55:00
11:57:41 5 12:00:00
11:17:41 0 12:00:00
11:17:41 1 11:08:00

public static NextGivenMinuteDate ( DateTimeOffset date, int minuteBase ) : DateTimeOffset
date DateTimeOffset
minuteBase int
Résultat DateTimeOffset

NextGivenSecondDate() public static méthode

Returns a date that is rounded to the next even multiple of the given minute.
The rules for calculating the second are the same as those for calculating the minute in the method NextGivenMinuteDate.
public static NextGivenSecondDate ( DateTimeOffset date, int secondBase ) : DateTimeOffset
date DateTimeOffset the Date to round, if the current time will
secondBase int the base-second to set the time on
Résultat DateTimeOffset

OnDay() public méthode

Set the day of month (1-31) for the Date that will be built by this builder.
public OnDay ( int day ) : DateBuilder
day int
Résultat DateBuilder

TodayAt() public static méthode

Get a DateTimeOffset object that represents the given time, on today's date (equivalent to DateOf(int,int,int)).
public static TodayAt ( int hour, int minute, int second ) : DateTimeOffset
hour int
minute int
second int
Résultat DateTimeOffset

TomorrowAt() public static méthode

Get a DateTimeOffset object that represents the given time, on tomorrow's date.
public static TomorrowAt ( int hour, int minute, int second ) : DateTimeOffset
hour int
minute int
second int
Résultat DateTimeOffset

ValidateDayOfMonth() public static méthode

public static ValidateDayOfMonth ( int day ) : void
day int
Résultat void

ValidateHour() public static méthode

public static ValidateHour ( int hour ) : void
hour int
Résultat void

ValidateMinute() public static méthode

public static ValidateMinute ( int minute ) : void
minute int
Résultat void

ValidateMonth() public static méthode

public static ValidateMonth ( int month ) : void
month int
Résultat void

ValidateSecond() public static méthode

public static ValidateSecond ( int second ) : void
second int
Résultat void

ValidateYear() public static méthode

public static ValidateYear ( int year ) : void
year int
Résultat void