Package com.ibm.icu.util
Class SimpleDateRule
- java.lang.Object
-
- com.ibm.icu.util.SimpleDateRule
-
-
Field Summary
Fields Modifier and Type Field Description private Calendar
calendar
private int
dayOfMonth
private int
dayOfWeek
private int
month
-
Constructor Summary
Constructors Constructor Description SimpleDateRule(int month, int dayOfMonth)
Construct a rule for a fixed date within a monthSimpleDateRule(int month, int dayOfMonth, int dayOfWeek, boolean after)
Construct a rule for a weekday within a month, e.g.SimpleDateRule(int month, int dayOfMonth, Calendar cal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Date
computeInYear(int year, Calendar c)
private java.util.Date
doFirstBetween(java.util.Date start, java.util.Date end)
java.util.Date
firstAfter(java.util.Date start)
Return the first occurrance of the event represented by this rule that is on or after the given start date.java.util.Date
firstBetween(java.util.Date start, java.util.Date end)
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.boolean
isBetween(java.util.Date start, java.util.Date end)
Check whether this event occurs at least once between the two dates given.boolean
isOn(java.util.Date date)
Checks whether this event occurs on the given date.
-
-
-
Field Detail
-
calendar
private Calendar calendar
-
month
private int month
-
dayOfMonth
private int dayOfMonth
-
dayOfWeek
private int dayOfWeek
-
-
Constructor Detail
-
SimpleDateRule
public SimpleDateRule(int month, int dayOfMonth)
Construct a rule for a fixed date within a month- Parameters:
month
- The month in which this rule occurs (0-based).dayOfMonth
- The date in that month (1-based).
-
SimpleDateRule
SimpleDateRule(int month, int dayOfMonth, Calendar cal)
-
SimpleDateRule
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
- The month in which this rule occurs (0-based).dayOfMonth
- A date within that month (1-based).dayOfWeek
- The day of the week on which this rule occurs.after
- If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, the rule selects the first dayOfWeek on or before dayOfMonth.
-
-
Method Detail
-
firstAfter
public java.util.Date firstAfter(java.util.Date start)
Return the first occurrance of the event represented by this rule that is on or after the given start date.- Specified by:
firstAfter
in interfaceDateRule
- Parameters:
start
- Only occurrances on or after this date are returned.- Returns:
- The date on which this event occurs, or null if it does not occur on or after the start date.
- See Also:
firstBetween(java.util.Date, java.util.Date)
-
firstBetween
public java.util.Date firstBetween(java.util.Date start, java.util.Date end)
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.- Specified by:
firstBetween
in interfaceDateRule
- Parameters:
start
- Only occurrances on or after this date are returned.end
- Only occurrances before this date are returned.- Returns:
- The date on which this event occurs, or null if it does not occur between the start and end dates.
- See Also:
firstAfter(java.util.Date)
-
isOn
public boolean isOn(java.util.Date date)
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.
-
isBetween
public boolean isBetween(java.util.Date start, java.util.Date end)
Check whether this event occurs at least once between the two dates given.
-
doFirstBetween
private java.util.Date doFirstBetween(java.util.Date start, java.util.Date end)
-
computeInYear
private java.util.Date computeInYear(int year, Calendar c)
-
-