Package com.illumon.util.calendar
Class DefaultBusinessCalendar
java.lang.Object
com.illumon.util.calendar.AbstractCalendar
com.illumon.util.calendar.AbstractBusinessCalendar
com.illumon.util.calendar.DefaultBusinessCalendar
- All Implemented Interfaces:
BusinessCalendar
,Calendar
,Serializable
public class DefaultBusinessCalendar extends AbstractBusinessCalendar implements Serializable
Default implementation for a
BusinessCalendar
. This implementation is thread safe.
Overrides many default Calendar
and BusinessCalendar
methods for improved performance. See the documentation of Calendar
for details.- See Also:
- Serialized Form
-
Method Summary
Modifier and Type Method Description long
diffBusinessNanos(DBDateTime start, DBDateTime end)
Returns the amount of business time in nanoseconds betweenstart
andend
.double
diffBusinessYear(DBDateTime startTime, DBDateTime endTime)
Returns the number of business years betweenstart
andend
.boolean
equals(Object o)
BusinessSchedule
getBusinessDay(DBDateTime time)
Deprecated.BusinessSchedule
getBusinessDay(String date)
Deprecated.BusinessSchedule
getBusinessDay(LocalDate date)
Deprecated.BusinessSchedule
getBusinessSchedule(DBDateTime time)
Gets the indicated business day's schedule.BusinessSchedule
getBusinessSchedule(String date)
Gets the indicated business day's schedule.BusinessSchedule
getBusinessSchedule(LocalDate date)
Gets the indicated business day's schedule.List<String>
getDefaultBusinessPeriods()
Gets the business periods for the default days.Map<LocalDate,BusinessSchedule>
getHolidays()
Gets business schedules for dates that are different from the defaults.LocalDate
getLastHoliday()
Gets the date of the last holiday defined in the calendar.int
hashCode()
boolean
isBusinessDay(DayOfWeek day)
Is the day of the week a business day? A business day is a day that has a business schedule with one or more business periods defined.String
name()
Gets the name of the calendar.long
standardBusinessDayLengthNanos()
Returns the length of a standard business day in nanoseconds.DBTimeZone
timeZone()
Gets the timezone of the calendar.String
toString()
Methods inherited from class com.illumon.util.calendar.AbstractBusinessCalendar
businessDaysInRange, businessDaysInRange, diffBusinessDay, diffNonBusinessDay, diffNonBusinessNanos, fractionOfBusinessDayComplete, fractionOfBusinessDayRemaining, fractionOfStandardBusinessDay, fractionOfStandardBusinessDay, isBusinessDay, isBusinessDay, isBusinessDay, isBusinessTime, isLastBusinessDayOfMonth, isLastBusinessDayOfMonth, isLastBusinessDayOfWeek, isLastBusinessDayOfWeek, nextBusinessDay, nextBusinessDay, nextBusinessDay, nextBusinessDay, nextBusinessSchedule, nextBusinessSchedule, nextBusinessSchedule, nextBusinessSchedule, nextNonBusinessDay, nextNonBusinessDay, nextNonBusinessDay, nextNonBusinessDay, nonBusinessDaysInRange, nonBusinessDaysInRange, numberOfBusinessDays, numberOfBusinessDays, numberOfBusinessDays, numberOfBusinessDays, numberOfNonBusinessDays, numberOfNonBusinessDays, numberOfNonBusinessDays, numberOfNonBusinessDays, previousBusinessDay, previousBusinessDay, previousBusinessDay, previousBusinessDay, previousBusinessSchedule, previousBusinessSchedule, previousBusinessSchedule, previousBusinessSchedule, previousNonBusinessDay, previousNonBusinessDay, previousNonBusinessDay, previousNonBusinessDay
Methods inherited from class com.illumon.util.calendar.AbstractCalendar
dayOfWeek, dayOfWeek, daysInRange, daysInRange, diffDay, diffNanos, diffYear, nextDay, nextDay, nextDay, nextDay, numberOfDays, numberOfDays, numberOfDays, numberOfDays, previousDay, previousDay, previousDay, previousDay
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.util.calendar.BusinessCalendar
currentBusinessSchedule, fractionOfStandardBusinessDay, isBusinessDay, isLastBusinessDayOfMonth, isLastBusinessDayOfWeek, nextBusinessDay, nextBusinessDay, nextBusinessSchedule, nextBusinessSchedule, nextNonBusinessDay, nextNonBusinessDay, previousBusinessDay, previousBusinessDay, previousBusinessSchedule, previousBusinessSchedule, previousNonBusinessDay, previousNonBusinessDay
Methods inherited from interface com.illumon.util.calendar.Calendar
currentDay, dayOfWeek, dayOfWeek, dayOfWeek, daysInRange, daysInRange, diffDay, diffNanos, diffYear, nextDay, nextDay, nextDay, nextDay, nextDay, nextDay, numberOfDays, numberOfDays, numberOfDays, numberOfDays, previousDay, previousDay, previousDay, previousDay, previousDay, previousDay
-
Method Details
-
getDefaultBusinessPeriods
Description copied from interface:BusinessCalendar
Gets the business periods for the default days.- Specified by:
getDefaultBusinessPeriods
in interfaceBusinessCalendar
- Returns:
- a list of strings with a comma separating open and close times
-
getHolidays
Description copied from interface:BusinessCalendar
Gets business schedules for dates that are different from the defaults. This returns all dates that are defined as a holiday for the calendar.- Specified by:
getHolidays
in interfaceBusinessCalendar
- Returns:
- a map of dates and to their business periods
-
isBusinessDay
Description copied from interface:BusinessCalendar
Is the day of the week a business day? A business day is a day that has a business schedule with one or more business periods defined.- Specified by:
isBusinessDay
in interfaceBusinessCalendar
- Parameters:
day
- a day of the week- Returns:
- true if the day is a business day; false otherwise.
-
name
Description copied from interface:Calendar
Gets the name of the calendar. -
timeZone
Description copied from interface:Calendar
Gets the timezone of the calendar. -
standardBusinessDayLengthNanos
public long standardBusinessDayLengthNanos()Description copied from interface:BusinessCalendar
Returns the length of a standard business day in nanoseconds.- Specified by:
standardBusinessDayLengthNanos
in interfaceBusinessCalendar
- Returns:
- length of a standard business day in nanoseconds.
-
getBusinessDay
Deprecated.Description copied from interface:BusinessCalendar
Gets the indicated business day.- Specified by:
getBusinessDay
in interfaceBusinessCalendar
- Parameters:
time
- time- Returns:
- the corresponding BusinessSchedule of
time
; null if time is null
-
getBusinessDay
Deprecated.Description copied from interface:BusinessCalendar
Gets the indicated business day.- Specified by:
getBusinessDay
in interfaceBusinessCalendar
- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getBusinessDay
Deprecated.Description copied from interface:BusinessCalendar
Gets the indicated business day.- Specified by:
getBusinessDay
in interfaceBusinessCalendar
- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getBusinessSchedule
Description copied from interface:BusinessCalendar
Gets the indicated business day's schedule.getBusinessSchedule(null)
returnsnull
.- Specified by:
getBusinessSchedule
in interfaceBusinessCalendar
- Parameters:
time
- time- Returns:
- the corresponding BusinessSchedule of
time
; null if time is null
-
getBusinessSchedule
Description copied from interface:BusinessCalendar
Gets the indicated business day's schedule.getBusinessSchedule(null)
returnsnull
.- Specified by:
getBusinessSchedule
in interfaceBusinessCalendar
- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getBusinessSchedule
Description copied from interface:BusinessCalendar
Gets the indicated business day's schedule.getBusinessSchedule(null)
returnsnull
.- Specified by:
getBusinessSchedule
in interfaceBusinessCalendar
- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getLastHoliday
Description copied from interface:BusinessCalendar
Gets the date of the last holiday defined in the calendar.- Specified by:
getLastHoliday
in interfaceBusinessCalendar
- Returns:
- the date of the last holiday, or
LocalDate.MAX
if no holiday dates are defined
-
diffBusinessNanos
Description copied from interface:BusinessCalendar
Returns the amount of business time in nanoseconds betweenstart
andend
.- Specified by:
diffBusinessNanos
in interfaceBusinessCalendar
- Parameters:
start
- start time; if null, return NULL_LONGend
- end time; if null, return NULL_LONG- Returns:
- the amount of business time in nanoseconds between the
start
andend
-
diffBusinessYear
Description copied from interface:BusinessCalendar
Returns the number of business years betweenstart
andend
.- Specified by:
diffBusinessYear
in interfaceBusinessCalendar
- Parameters:
startTime
- start; if null, return nullendTime
- end; if null, return null- Returns:
- the amount of business time in business years between the
start
andend
-
toString
-
equals
-
hashCode
public int hashCode()
-