Class BaseCalendar
- java.lang.Object
-
- org.quartz.impl.calendar.BaseCalendar
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Calendar
- Direct Known Subclasses:
AnnualCalendar
,CronCalendar
,DailyCalendar
,HolidayCalendar
,MonthlyCalendar
,WeeklyCalendar
public class BaseCalendar extends java.lang.Object implements Calendar, java.io.Serializable, java.lang.Cloneable
This implementation of the Calendar may be used (you don't have to) as a base class for more sophisticated one's. It merely implements the base functionality required by each Calendar.
Regarded as base functionality is the treatment of base calendars. Base calendar allow you to chain (stack) as much calendars as you may need. For example to exclude weekends you may use WeeklyCalendar. In order to exclude holidays as well you may define a WeeklyCalendar instance to be the base calendar for HolidayCalendar instance.
- Author:
- Juergen Donnerstag, James House
- See Also:
Calendar
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BaseCalendar()
BaseCalendar(java.util.TimeZone timeZone)
BaseCalendar(Calendar baseCalendar)
BaseCalendar(Calendar baseCalendar, java.util.TimeZone timeZone)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
protected java.util.Calendar
createJavaCalendar()
Build a
with the current time.Calendar
protected java.util.Calendar
createJavaCalendar(long timeStamp)
Build a
for the given timeStamp.Calendar
Calendar
getBaseCalendar()
Get the base calendar.java.lang.String
getDescription()
Return the description given to theCalendar
instance by its creator (if any).protected java.util.Calendar
getEndOfDayJavaCalendar(long timeInMillis)
Returns the end of the given day
.Calendar
long
getNextIncludedTime(long timeStamp)
Determine the next time (in milliseconds) that is 'included' by the Calendar after the given time.protected java.util.Calendar
getStartOfDayJavaCalendar(long timeInMillis)
Returns the start of the given day as a
.Calendar
java.util.TimeZone
getTimeZone()
Returns the time zone for which thisCalendar
will be resolved.boolean
isTimeIncluded(long timeStamp)
Check if date/time represented by timeStamp is included.void
setBaseCalendar(Calendar baseCalendar)
Set a new base calendar or remove the existing onevoid
setDescription(java.lang.String description)
Set a description for theCalendar
instance - may be useful for remembering/displaying the purpose of the calendar, though the description has no meaning to Quartz.void
setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which thisCalendar
will be resolved.
-
-
-
Constructor Detail
-
BaseCalendar
public BaseCalendar()
-
BaseCalendar
public BaseCalendar(Calendar baseCalendar)
-
BaseCalendar
public BaseCalendar(java.util.TimeZone timeZone)
- Parameters:
timeZone
- The time zone to use for this Calendar,null
if
should be usedTimeZone.getDefault()
-
BaseCalendar
public BaseCalendar(Calendar baseCalendar, java.util.TimeZone timeZone)
- Parameters:
timeZone
- The time zone to use for this Calendar,null
if
should be usedTimeZone.getDefault()
-
-
Method Detail
-
clone
public java.lang.Object clone()
-
setBaseCalendar
public void setBaseCalendar(Calendar baseCalendar)
Set a new base calendar or remove the existing one
- Specified by:
setBaseCalendar
in interfaceCalendar
-
getBaseCalendar
public Calendar getBaseCalendar()
Get the base calendar. Will be null, if not set.
- Specified by:
getBaseCalendar
in interfaceCalendar
-
getDescription
public java.lang.String getDescription()
Return the description given to the
Calendar
instance by its creator (if any).- Specified by:
getDescription
in interfaceCalendar
- Returns:
- null if no description was set.
-
setDescription
public void setDescription(java.lang.String description)
Set a description for the
Calendar
instance - may be useful for remembering/displaying the purpose of the calendar, though the description has no meaning to Quartz.- Specified by:
setDescription
in interfaceCalendar
-
getTimeZone
public java.util.TimeZone getTimeZone()
Returns the time zone for which thisCalendar
will be resolved.- Returns:
- This Calendar's timezone,
null
if Calendar should use theTimeZone.getDefault()
-
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which thisCalendar
will be resolved.- Parameters:
timeZone
- The time zone to use for this Calendar,null
if
should be usedTimeZone.getDefault()
-
isTimeIncluded
public boolean isTimeIncluded(long timeStamp)
Check if date/time represented by timeStamp is included. If included return true. The implementation of BaseCalendar simply calls the base calendars isTimeIncluded() method if base calendar is set.
- Specified by:
isTimeIncluded
in interfaceCalendar
- See Also:
Calendar.isTimeIncluded(long)
-
getNextIncludedTime
public long getNextIncludedTime(long timeStamp)
Determine the next time (in milliseconds) that is 'included' by the Calendar after the given time. Return the original value if timeStamp is included. Return 0 if all days are excluded.
- Specified by:
getNextIncludedTime
in interfaceCalendar
- See Also:
Calendar.getNextIncludedTime(long)
-
createJavaCalendar
protected java.util.Calendar createJavaCalendar(long timeStamp)
Build a
for the given timeStamp. The new Calendar will use theCalendar
BaseCalendar
time zone if it is notnull
.
-
createJavaCalendar
protected java.util.Calendar createJavaCalendar()
Build a
with the current time. The new Calendar will use theCalendar
BaseCalendar
time zone if it is notnull
.
-
getStartOfDayJavaCalendar
protected java.util.Calendar getStartOfDayJavaCalendar(long timeInMillis)
Returns the start of the given day as a
. This calculation will take theCalendar
BaseCalendar
time zone into account if it is notnull
.- Parameters:
timeInMillis
- A time containing the desired date for the start-of-day time- Returns:
- A
set to the start of the given day.Calendar
-
getEndOfDayJavaCalendar
protected java.util.Calendar getEndOfDayJavaCalendar(long timeInMillis)
Returns the end of the given day
. This calculation will take theCalendar
BaseCalendar
time zone into account if it is notnull
.- Parameters:
timeInMillis
- a time containing the desired date for the end-of-day time.- Returns:
- A
set to the end of the given day.Calendar
-
-