Package com.ibm.icu.util
Class Holiday
- java.lang.Object
-
- com.ibm.icu.util.Holiday
-
- All Implemented Interfaces:
DateRule
- Direct Known Subclasses:
EasterHoliday
,HebrewHoliday
,SimpleHoliday
public abstract class Holiday extends java.lang.Object implements DateRule
Note: The Holiday framework is a technology preview. Despite its age, is still draft API, and clients should treat it as such. An abstract class representing a holiday.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
name
private static Holiday[]
noHolidays
private DateRule
rule
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Date
firstAfter(java.util.Date start)
Return the first occurrence of this holiday on or after the given datejava.util.Date
firstBetween(java.util.Date start, java.util.Date end)
Return the first occurrence of this holiday that is on or after the given start date and before the given end date.java.lang.String
getDisplayName()
Return the name of this holiday in the language of the defaultDISPLAY
locale.java.lang.String
getDisplayName(ULocale locale)
Return the name of this holiday in the language of the specified locale Thename
parameter passed to this object's constructor is used as a key to look up the holiday's localized name in a ResourceBundle object named HolidayBundle.java.lang.String
getDisplayName(java.util.Locale locale)
Return the name of this holiday in the language of the specified locale.static Holiday[]
getHolidays()
static Holiday[]
getHolidays(ULocale locale)
static Holiday[]
getHolidays(java.util.Locale locale)
DateRule
getRule()
boolean
isBetween(java.util.Date start, java.util.Date end)
Check whether this holiday occurs at least once between the two dates given.boolean
isOn(java.util.Date date)
Checks whether this holiday falls on the given date.void
setRule(DateRule rule)
-
-
-
Constructor Detail
-
Holiday
protected Holiday(java.lang.String name, DateRule rule)
Construct a new Holiday object. This is for use by subclasses only. This constructs a new holiday with the given name and date rules.- Parameters:
name
- The name of this holiday. The getDisplayName method uses this string as a key to look up the holiday's name a resource bundle object named HolidayBundle.rule
- The date rules used for determining when this holiday falls. Holiday's implementation of the DateRule interface simply delegates to this DateRule object.
-
-
Method Detail
-
getHolidays
public static Holiday[] getHolidays()
-
getHolidays
public static Holiday[] getHolidays(java.util.Locale locale)
-
firstAfter
public java.util.Date firstAfter(java.util.Date start)
Return the first occurrence of this holiday on or after the given date- Specified by:
firstAfter
in interfaceDateRule
- Parameters:
start
- Only holidays on or after this date are returned.- Returns:
- The date on which this holiday 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 occurrence of this holiday that is on or after the given start date and before the given end date.- Specified by:
firstBetween
in interfaceDateRule
- Parameters:
start
- Only occurrences on or after this date are returned.end
- Only occurrences 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 holiday falls on the given date. This does not take time of day into account; instead it checks whether the holiday and the given date are on the same day.
-
isBetween
public boolean isBetween(java.util.Date start, java.util.Date end)
Check whether this holiday occurs at least once between the two dates given.
-
getDisplayName
public java.lang.String getDisplayName()
Return the name of this holiday in the language of the defaultDISPLAY
locale.- See Also:
ULocale.Category.DISPLAY
-
getDisplayName
public java.lang.String getDisplayName(java.util.Locale locale)
Return the name of this holiday in the language of the specified locale. Thename
parameter passed to this object's constructor is used as a key to look up the holiday's localized name in a ResourceBundle object named HolidayBundle.- Parameters:
locale
- A locale specifying the language in which the name is desired.- See Also:
ResourceBundle
-
getDisplayName
public java.lang.String getDisplayName(ULocale locale)
Return the name of this holiday in the language of the specified locale Thename
parameter passed to this object's constructor is used as a key to look up the holiday's localized name in a ResourceBundle object named HolidayBundle.- Parameters:
locale
- A locale specifying the language in which the name is desired.- See Also:
ResourceBundle
-
getRule
public DateRule getRule()
-
setRule
public void setRule(DateRule rule)
-
-