Top Description Fields Constructors Methods
com.ibm.icu.util

public Class SimpleDateRule

extends Object
implements DateRule
Class Inheritance
All Implemented Interfaces
com.ibm.icu.util.DateRule
Imports
java.util.Date

Note

The Holiday framework is a technology preview. Despite its age, is still draft API, and clients should treat it as such. Simple implementation of DateRule.

ICU Status
Draft since ICU 2.8 (retainAll).

Field Summary

Modifier and TypeField and Description
private Calendar
private int
private int
private int

Constructor Summary

AccessConstructor and Description
public
SimpleDateRule(int
The month in which this rule occurs (0-based).
month
,
int
The date in that month (1-based).
dayOfMonth
)

Construct a rule for a fixed date within a month

pack-priv
SimpleDateRule(int month, int dayOfMonth, Calendar cal)

public
SimpleDateRule(int
The month in which this rule occurs (0-based).
month
,
int
A date within that month (1-based).
dayOfMonth
,
int
The day of the week on which this rule occurs.
dayOfWeek
,
boolean
If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, the rule selects the first dayOfWeek on or before dayOfMonth.
after
)

Construct a rule for a weekday within a month, e.g. the first Monday.

Method Summary

Modifier and TypeMethod and Description
private Date
computeInYear(int year, Calendar c)

private Date
doFirstBetween(Date start, Date end)

public Date

Returns:

The date on which this event occurs, or null if it does not occur on or after the start date.
firstAfter
(Date
Only occurrances on or after this date are returned.
start
)

Implements com.ibm.icu.util.DateRule.firstAfter.

Return the first occurrance of the event represented by this rule that is on or after the given start date.
public Date

Returns:

The date on which this event occurs, or null if it does not occur between the start and end dates.
firstBetween
(Date
Only occurrances on or after this date are returned.
start
,
Date
Only occurrances before this date are returned.
end
)

Implements com.ibm.icu.util.DateRule.firstBetween.

Return the first occurrance of the event represented by this rule that is on or after the given start date and before the given end date.
public boolean
isBetween(Date start, Date end)

Implements com.ibm.icu.util.DateRule.isBetween.

Check whether this event occurs at least once between the two dates given.
public boolean

Returns:

true if this event occurs on the given date.
isOn
(Date
The date to check.
date
)

Implements com.ibm.icu.util.DateRule.isOn.

Checks whether this event occurs on the given date.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

calendarback to summary
private Calendar calendar
dayOfMonthback to summary
private int dayOfMonth
dayOfWeekback to summary
private int dayOfWeek
monthback to summary
private int month

Constructor Detail

SimpleDateRuleback to summary
public SimpleDateRule(int month, int dayOfMonth)

Construct a rule for a fixed date within a month

Parameters
month:int

The month in which this rule occurs (0-based).

dayOfMonth:int

The date in that month (1-based).

ICU Status
Draft since ICU 2.8.
SimpleDateRuleback to summary
pack-priv SimpleDateRule(int month, int dayOfMonth, Calendar cal)
SimpleDateRuleback to summary
public SimpleDateRule(int month, int dayOfMonth, int dayOfWeek, boolean after)

Construct a rule for a weekday within a month, e.g. the first Monday.

Parameters
month:int

The month in which this rule occurs (0-based).

dayOfMonth:int

A date within that month (1-based).

dayOfWeek:int

The day of the week on which this rule occurs.

after:boolean

If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, the rule selects the first dayOfWeek on or before dayOfMonth.

ICU Status
Draft since ICU 2.8.

Method Detail

computeInYearback to summary
private Date computeInYear(int year, Calendar c)
doFirstBetweenback to summary
private Date doFirstBetween(Date start, Date end)
firstAfterback to summary
public Date firstAfter(Date start)

Implements com.ibm.icu.util.DateRule.firstAfter.

Return the first occurrance of the event represented by this rule that is on or after the given start date.

Parameters
start:Date

Only occurrances on or after this date are returned.

Returns:Date

The date on which this event occurs, or null if it does not occur on or after the start date.

Annotations
@Override
ICU Status
Draft since ICU 2.8.
See Also
firstBetween
firstBetweenback to summary
public Date firstBetween(Date start, Date end)

Implements com.ibm.icu.util.DateRule.firstBetween.

Return the first occurrance of the event represented by this rule that is on or after the given start date and before the given end date.

Parameters
start:Date

Only occurrances on or after this date are returned.

end:Date

Only occurrances before this date are returned.

Returns:Date

The date on which this event occurs, or null if it does not occur between the start and end dates.

Annotations
@Override
ICU Status
Draft since ICU 2.8.
See Also
firstAfter
isBetweenback to summary
public boolean isBetween(Date start, Date end)

Implements com.ibm.icu.util.DateRule.isBetween.

Check whether this event occurs at least once between the two dates given.

Annotations
@Override
ICU Status
Draft since ICU 2.8.
isOnback to summary
public boolean isOn(Date date)

Implements com.ibm.icu.util.DateRule.isOn.

Checks whether this event occurs on the given date. This does not take time of day into account; instead it checks whether this event and the given date are on the same day. This is useful for applications such as determining whether a given day is a holiday.

Parameters
date:Date

The date to check.

Returns:boolean

true if this event occurs on the given date.

Annotations
@Override
ICU Status
Draft since ICU 2.8.