public abstract class AbstractCalendar<IMPLTYPE extends AbstractCalendar<IMPLTYPE>> extends Object implements ICalendar, com.helger.commons.lang.ICloneable<IMPLTYPE>
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.
ICalendar| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCalendar(AbstractCalendar<IMPLTYPE> aOther)
Copy constructor
|
|
AbstractCalendar(ICalendar aBaseCalendar,
TimeZone aTimeZone) |
| Modifier and Type | Method and Description |
|---|---|
protected Calendar |
createJavaCalendar()
Build a
with the current time. |
protected Calendar |
createJavaCalendar(long timeStamp)
Build a
for the given timeStamp. |
ICalendar |
getBaseCalendar()
Get the base calendar.
|
String |
getDescription()
Return the description given to the
Calendar instance by its
creator (if any). |
protected Calendar |
getEndOfDayJavaCalendar(long timeInMillis)
Returns the end of the given day
. |
long |
getNextIncludedTime(long timeStamp)
Determine the next time (in milliseconds) that is 'included' by the
Calendar after the given time.
|
protected Calendar |
getStartOfDayJavaCalendar(long timeInMillis)
Returns the start of the given day as a
. |
TimeZone |
getTimeZone() |
boolean |
isTimeIncluded(long timeStamp)
Check if date/time represented by timeStamp is included.
|
void |
setBaseCalendar(ICalendar baseCalendar)
Set a new base calendar or remove the existing one.
|
void |
setDescription(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. |
void |
setTimeZone(TimeZone timeZone) |
protected AbstractCalendar(@Nonnull AbstractCalendar<IMPLTYPE> aOther)
aOther - Calendar to copy from. May not be null.public AbstractCalendar(@Nullable ICalendar aBaseCalendar, @Nullable TimeZone aTimeZone)
aBaseCalendar - Base calendar to use. May be null.aTimeZone - The time zone to use for this Calendar, null if
TimeZone.getDefault() should be usedpublic final ICalendar getBaseCalendar()
ICalendarnull, if not set.getBaseCalendar in interface ICalendarpublic final void setBaseCalendar(@Nullable ICalendar baseCalendar)
ICalendarsetBaseCalendar in interface ICalendarbaseCalendar - The new base calendar. May be null.public final String getDescription()
ICalendarCalendar instance by its
creator (if any).getDescription in interface ICalendarnull if no description was set.public final void setDescription(@Nullable String description)
ICalendarCalendar instance - may be useful
for remembering/displaying the purpose of the calendar, though the
description has no meaning to Quartz.setDescription in interface ICalendardescription - The new description. May be null.public boolean isTimeIncluded(long timeStamp)
Check if date/time represented by timeStamp is included. If included return true. The implementation of AbstractCalendar simply calls the base calendars isTimeIncluded() method if base calendar is set.
isTimeIncluded in interface ICalendarICalendar.isTimeIncluded(long)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.
getNextIncludedTime in interface ICalendarICalendar.getNextIncludedTime(long)protected final Calendar createJavaCalendar(long timeStamp)
Calendar for the given timeStamp. The new
Calendar will use the AbstractCalendar time zone if it is not
null.protected final Calendar createJavaCalendar()
Calendar with the current time. The new
Calendar will use the AbstractCalendar time zone if it is not
null.protected final Calendar getStartOfDayJavaCalendar(long timeInMillis)
Calendar. This
calculation will take the AbstractCalendar time zone into
account if it is not null.timeInMillis - A time containing the desired date for the start-of-day timeCalendar set to the start of the given day.protected final Calendar getEndOfDayJavaCalendar(long timeInMillis)
Calendar. This
calculation will take the AbstractCalendar time zone into
account if it is not null.timeInMillis - a time containing the desired date for the end-of-day time.Calendar set to the end of the given day.Copyright © 2016–2021 Philip Helger. All rights reserved.