Package com.illumon.util.calendar
Interface BusinessCalendar
- All Superinterfaces:
Calendar
- All Known Implementing Classes:
AbstractBusinessCalendar
,DefaultBusinessCalendar
,DefaultNoHolidayBusinessCalendar
A business calendar. Calendar is extended with the concept of business and non-business time.
To comply with the ISO-8601 standard for dates, Strings should
be of the form "yyyy-MM-dd",
-
Method Summary
Modifier and TypeMethodDescriptionString[]
businessDaysInRange
(DBDateTime start, DBDateTime end) Returns the business days betweenstart
andend
, inclusive.String[]
businessDaysInRange
(String start, String end) Returns the business days betweenstart
andend
, inclusive.default BusinessSchedule
Gets today's business schedule.double
diffBusinessDay
(DBDateTime start, DBDateTime end) Returns the amount of business time in standard business days betweenstart
andend
.long
diffBusinessNanos
(DBDateTime start, DBDateTime end) Returns the amount of business time in nanoseconds betweenstart
andend
.double
diffBusinessYear
(DBDateTime start, DBDateTime end) Returns the number of business years betweenstart
andend
.double
diffNonBusinessDay
(DBDateTime start, DBDateTime end) Returns the amount of non-business time in standard business days betweenstart
andend
.long
diffNonBusinessNanos
(DBDateTime start, DBDateTime end) Returns the amount of non-business time in nanoseconds betweenstart
andend
.double
Returns the fraction of the business day complete by the given time.double
Returns the fraction of the business day remaining after the given time.default double
Returns the ratio of the current day's business day length and the standard business day length.double
For the given date, returns the ratio of the business day length and the standard business day length.double
For the given date, returns the ratio of the business day length and the standard business day length.getBusinessDay
(DBDateTime time) Deprecated.getBusinessDay
(String date) Deprecated.getBusinessDay
(LocalDate date) Deprecated.Gets the indicated business day's schedule.getBusinessSchedule
(String date) Gets the indicated business day's schedule.getBusinessSchedule
(LocalDate date) Gets the indicated business day's schedule.Gets the business periods for the default days.Gets business schedules for dates that are different from the defaults.default LocalDate
Gets the date of the last holiday defined in the calendar.default boolean
Is the current day a business day?boolean
isBusinessDay
(DBDateTime time) Does time occur on a business day?boolean
isBusinessDay
(String date) Is the date a business day?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.boolean
isBusinessDay
(LocalDate date) Is the date a business day?boolean
isBusinessTime
(DBDateTime time) Determines if the specified time is a business time.default boolean
Is the current day the last business day of the month?boolean
Is the time on the last business day of the month with business time remaining?boolean
Is the date the last business day of the month?default boolean
Is the current day the last business day of the week?boolean
Is the time on the last business day of the week with business time remaining?boolean
Is the date the last business day of the week?default String
Gets the next business day.default String
nextBusinessDay
(int days) Gets the business datedays
business days after the current day.nextBusinessDay
(DBDateTime time) Gets the next business day.nextBusinessDay
(DBDateTime time, int days) Gets the business datedays
business days after inputtime
.nextBusinessDay
(String date) Gets the next business day.nextBusinessDay
(String date, int days) Gets the business datedays
business days after inputdate
.default BusinessSchedule
Gets the next business schedule.default BusinessSchedule
nextBusinessSchedule
(int days) Gets the business scheduledays
days after the current day.Gets the next business schedule.nextBusinessSchedule
(DBDateTime time, int days) Gets the business scheduledays
days after inputtime
.nextBusinessSchedule
(String date) Gets the next business schedule after inputdate
.nextBusinessSchedule
(String date, int days) Gets the business scheduledays
days after inputdate
.default String
Gets the next non-business day.default String
nextNonBusinessDay
(int days) Gets the non-business datedays
non-business days after the current day.nextNonBusinessDay
(DBDateTime time) Gets the next non-business day.nextNonBusinessDay
(DBDateTime time, int days) Gets the non-business datedays
non-business days after inputtime
.nextNonBusinessDay
(String date) Gets the next non-business day.nextNonBusinessDay
(String date, int days) Gets the non-business datedays
non-business days after inputdate
.String[]
nonBusinessDaysInRange
(DBDateTime start, DBDateTime end) Returns the non-business days betweenstart
andend
, inclusive.String[]
nonBusinessDaysInRange
(String start, String end) Returns the non-business days betweenstart
andend
, inclusive.int
numberOfBusinessDays
(DBDateTime start, DBDateTime end) Returns the number of business days betweenstart
andend
.int
numberOfBusinessDays
(DBDateTime start, DBDateTime end, boolean endInclusive) Returns the number of business days betweenstart
andend
.int
numberOfBusinessDays
(String start, String end) Returns the number of business days betweenstart
andend
.int
numberOfBusinessDays
(String start, String end, boolean endInclusive) Returns the number of business days betweenstart
andend
.int
numberOfNonBusinessDays
(DBDateTime start, DBDateTime end) Returns the number of non-business days betweenstart
andend
.int
numberOfNonBusinessDays
(DBDateTime start, DBDateTime end, boolean endInclusive) Returns the number of non-business days betweenstart
andend
.int
numberOfNonBusinessDays
(String start, String end) Returns the number of non-business days betweenstart
andend
.int
numberOfNonBusinessDays
(String start, String end, boolean endInclusive) Returns the number of non-business days betweenstart
andend
.default String
Gets the previous business day.default String
previousBusinessDay
(int days) Gets the business datedays
business days before the current day.Gets the previous business day.previousBusinessDay
(DBDateTime time, int days) Gets the business datedays
business days before inputtime
.previousBusinessDay
(String date) Gets the previous business day.previousBusinessDay
(String date, int days) Gets the business datedays
business days before inputdate
.default BusinessSchedule
Gets the previous business schedule.default BusinessSchedule
previousBusinessSchedule
(int days) Gets the business scheduledays
days before the current day.Gets the previous business schedule before inputtime
.previousBusinessSchedule
(DBDateTime time, int days) Gets the business scheduledays
days before inputtime
.Gets the business schedule before inputdate
.previousBusinessSchedule
(String date, int days) Gets the business scheduledays
days before inputdate
.default String
Gets the previous non-business day.default String
previousNonBusinessDay
(int days) Gets the non-business datedays
non-business days before the current day.Gets the previous non-business day.previousNonBusinessDay
(DBDateTime time, int days) Gets the non-business datedays
non-business days before inputtime
.previousNonBusinessDay
(String date) Gets the previous non-business day.previousNonBusinessDay
(String date, int days) Gets the non-business datedays
non-business days before inputdate
.long
Returns the length of a standard business day in nanoseconds.Methods inherited from interface com.illumon.util.calendar.Calendar
currentDay, dayOfWeek, dayOfWeek, dayOfWeek, daysInRange, daysInRange, diffDay, diffNanos, diffYear, name, nextDay, nextDay, nextDay, nextDay, nextDay, nextDay, numberOfDays, numberOfDays, numberOfDays, numberOfDays, previousDay, previousDay, previousDay, previousDay, previousDay, previousDay, timeZone
-
Method Details
-
getDefaultBusinessPeriods
Gets the business periods for the default days.- Returns:
- a list of strings with a comma separating open and close times
-
getHolidays
Map<LocalDate,BusinessSchedule> getHolidays()Gets business schedules for dates that are different from the defaults. This returns all dates that are defined as a holiday for the calendar.- Returns:
- a map of dates and to their business periods
-
currentBusinessSchedule
Gets today's business schedule.- Returns:
- today's business schedule
-
isBusinessDay
default boolean isBusinessDay()Is the current day a business day?- Returns:
- true if the current day is a business day; false otherwise.
-
isBusinessDay
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.- Parameters:
day
- a day of the week- Returns:
- true if the day is a business day; false otherwise.
-
isBusinessDay
Does time occur on a business day?- Parameters:
time
- time- Returns:
- true if the date is a business day; false otherwise.
-
isBusinessDay
Is the date a business day?- Parameters:
date
- date- Returns:
- true if the date is a business day; false otherwise.
-
isBusinessDay
Is the date a business day?- Parameters:
date
- date- Returns:
- true if the date is a business day; false otherwise.
-
isBusinessTime
Determines if the specified time is a business time. If the time falls between business periods, false will be returned.- Parameters:
time
- time- Returns:
- true if the specified time is a business time; otherwise, false.
-
previousBusinessDay
Gets the previous business day.- Returns:
- previous business day
-
previousBusinessDay
Gets the business datedays
business days before the current day. Ifdays
is zero and today is not a business day, null is returned.- Parameters:
days
- number of days- Returns:
- the business date
days
business days before the current day
-
previousBusinessDay
Gets the previous business day.- Parameters:
time
- time; if null, return null- Returns:
- the most recent business day before
time
-
previousBusinessDay
Gets the business datedays
business days before inputtime
. Ifdays
is zero and the day is not a business day, null is returned.- Parameters:
time
- time; if null, return nulldays
- number of days- Returns:
- the business date
days
business days before inputtime
-
previousBusinessDay
Gets the previous business day.- Parameters:
date
- date; if null, return null- Returns:
- the most recent business day before
date
-
previousBusinessDay
Gets the business datedays
business days before inputdate
. Ifdays
is zero and the day is not a business day, null is returned.- Parameters:
date
- date; if null, return nulldays
- number of days- Returns:
- the business date
days
business days before inputdate
-
previousBusinessSchedule
Gets the previous business schedule.- Returns:
- previous business schedule
-
previousBusinessSchedule
Gets the business scheduledays
days before the current day. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
days
- number of days- Returns:
- the business schedule
days
days before the current day
-
previousBusinessSchedule
Gets the previous business schedule before inputtime
. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
time
- time; if null, return null- Returns:
- the most recent business schedule before
time
-
previousBusinessSchedule
Gets the business scheduledays
days before inputtime
. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
time
- time; if null, return nulldays
- number of days
-
previousBusinessSchedule
Gets the business schedule before inputdate
. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
date
- date; if null, return null- Returns:
- the most recent business schedule before
date
-
previousBusinessSchedule
Gets the business scheduledays
days before inputdate
. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
date
- date; if null, return nulldays
- number of days- Returns:
- the business schedule
days
days before inputdate
-
previousNonBusinessDay
Gets the previous non-business day.- Returns:
- the most recent non-business day before the current day
-
previousNonBusinessDay
Gets the non-business datedays
non-business days before the current day. Ifdays
is zero and the day is a business day, null is returned.- Parameters:
days
- number of days- Returns:
- the non-business date
days
non-business days before the current day
-
previousNonBusinessDay
Gets the previous non-business day.- Parameters:
time
- time; if null, return null- Returns:
- the most recent non-business day before
time
-
previousNonBusinessDay
Gets the non-business datedays
non-business days before inputtime
. Ifdays
is zero and the day is a business day, null is returned.- Parameters:
time
- time; if null, return nulldays
- number of days- Returns:
- the non-business date
days
non-business days before inputtime
-
previousNonBusinessDay
Gets the previous non-business day.- Parameters:
date
- date; if null, return null- Returns:
- the most recent non-business day before
date
-
previousNonBusinessDay
Gets the non-business datedays
non-business days before inputdate
. Ifdays
is zero and the day is a business day, null is returned.- Parameters:
date
- date; if null, return nulldays
- number of days- Returns:
- the non-business date
days
non-business days before inputdate
-
nextBusinessDay
Gets the next business day.- Returns:
- next business day
-
nextBusinessDay
Gets the business datedays
business days after the current day. Ifdays
is zero and today is not a business day, null is returned.- Parameters:
days
- number of days- Returns:
- the business date
days
business days after the current day
-
nextBusinessDay
Gets the next business day.- Parameters:
time
- time; if null, return null- Returns:
- the next business day after
time
-
nextBusinessDay
Gets the business datedays
business days after inputtime
. Ifdays
is zero and the day is not a business day, null is returned.- Parameters:
time
- time; if null, return nulldays
- number of days- Returns:
- the next business day after
time
-
nextBusinessDay
Gets the next business day.- Parameters:
date
- date; if null, return null- Returns:
- the next business day after
date
-
nextBusinessDay
Gets the business datedays
business days after inputdate
. Ifdays
is zero and the day is not a business day, null is returned.- Parameters:
date
- date; if null, return nulldays
- number of days- Returns:
- the business date
days
business days after inputdate
-
nextBusinessSchedule
Gets the next business schedule.- Returns:
- next business schedule
-
nextBusinessSchedule
Gets the business scheduledays
days after the current day. If the current day is null, assumes the implementation of getBusinessSchedule(null) returns null.- Parameters:
days
- number of days- Returns:
- the next closest business schedule after the current day
-
nextBusinessSchedule
Gets the next business schedule.- Parameters:
time
- time; if null, return null- Returns:
- the next closest business schedule after
time
-
nextBusinessSchedule
Gets the business scheduledays
days after inputtime
. Ifdate
is null, assumes the implementation of getBusinessSchedule(null) returns null.- Parameters:
time
- time; if null, return nulldays
- number of days- Returns:
- the business schedule
days
aftertime
-
nextBusinessSchedule
Gets the next business schedule after inputdate
. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
date
- date; if null, return null- Returns:
- the next closest business schedule after
date
-
nextBusinessSchedule
Gets the business scheduledays
days after inputdate
. Ifdate
is null, assumes the implementation of getBusinessSchedule(null) returns null.- Parameters:
date
- date; if null, return nulldays
- number of days- Returns:
- the business schedule
days
afterdate
-
nextNonBusinessDay
Gets the next non-business day.- Returns:
- the next non-business day after the current day
-
nextNonBusinessDay
Gets the non-business datedays
non-business days after the current day. Ifdays
is zero and the day is a business day, null is returned.- Parameters:
days
- number of days- Returns:
- the non-business date
days
non-business days after the current day
-
nextNonBusinessDay
Gets the next non-business day.- Parameters:
time
- time; if null, return null- Returns:
- the next non-business day after
time
-
nextNonBusinessDay
Gets the non-business datedays
non-business days after inputtime
. Ifdays
is zero and the day is a business day, null is returned.- Parameters:
time
- time; if null, return nulldays
- number of days- Returns:
- the non-business date
days
non-business days after inputtime
-
nextNonBusinessDay
Gets the next non-business day.- Parameters:
date
- date; if null, return null- Returns:
- the next non-business day after
date
-
nextNonBusinessDay
Gets the non-business datedays
non-business days after inputdate
. Ifdays
is zero and the day is a business day, null is returned.- Parameters:
date
- date; if null, return nulldays
- number of days- Returns:
- the most recent business day before
time
-
businessDaysInRange
Returns the business days betweenstart
andend
, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstart
andend
will be included if they are business days.- Parameters:
start
- start time; if null, return empty arrayend
- end time; if null, return empty array- Returns:
- inclusive business days between
start
andend
-
businessDaysInRange
Returns the business days betweenstart
andend
, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstart
andend
will be included if they are business days.- Parameters:
start
- start time; if null, return empty arrayend
- end time; if null, return empty array- Returns:
- inclusive business days between
start
andend
-
nonBusinessDaysInRange
Returns the non-business days betweenstart
andend
, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstart
andend
will be included if they are non-business days.- Parameters:
start
- start time; if null, return empty arrayend
- end time; if null, return empty array- Returns:
- inclusive non-business days between
start
andend
-
nonBusinessDaysInRange
Returns the non-business days betweenstart
andend
, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstart
andend
will be included if they are non-business days.- Parameters:
start
- start time; if null, return empty arrayend
- end time; if null, return empty array- Returns:
- inclusive non-business days between
start
andend
-
standardBusinessDayLengthNanos
long standardBusinessDayLengthNanos()Returns the length of a standard business day in nanoseconds.- Returns:
- length of a standard business day in nanoseconds.
-
diffBusinessNanos
Returns the amount of business time in nanoseconds betweenstart
andend
.- 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
-
diffNonBusinessNanos
Returns the amount of non-business time in nanoseconds betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_LONGend
- end time; if null, return NULL_LONG- Returns:
- the amount of non-business time in nanoseconds between the
start
andend
-
diffBusinessDay
Returns the amount of business time in standard business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_LONGend
- end time; if null, return NULL_LONG- Returns:
- the amount of business time in standard business days between the
start
andend
-
diffNonBusinessDay
Returns the amount of non-business time in standard business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_LONGend
- end time; if null, return NULL_LONG- Returns:
- the amount of non-business time in standard business days between the
start
andend
-
diffBusinessYear
Returns the number of business years betweenstart
andend
.- Parameters:
start
- start; if null, return nullend
- end; if null, return null- Returns:
- the amount of business time in business years between the
start
andend
-
numberOfBusinessDays
Returns the number of business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_INTend
- end time; if null, return NULL_INT- Returns:
- number of business days between the
start
andend
, inclusive and exclusive respectively.
-
numberOfBusinessDays
Returns the number of business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_LONGend
- end time; if null, return NULL_LONGendInclusive
- whether to treat theend
inclusive or exclusively- Returns:
- number of business days between the
start
andend
, inclusive andendInclusive
respectively.
-
numberOfBusinessDays
Returns the number of business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_INTend
- end time; if null, return NULL_INT- Returns:
- number of business days between the
start
andend
, inclusive and exclusive respectively.
-
numberOfBusinessDays
Returns the number of business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_INTend
- end time; if null, return NULL_INTendInclusive
- whether to treat theend
inclusive or exclusively- Returns:
- number of business days between the
start
andend
, inclusive andendInclusive
respectively.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_INTend
- end time; if null, return NULL_INT- Returns:
- number of business days between the
start
andend
, inclusive and exclusive respectively.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_LONGend
- end time; if null, return NULL_LONGendInclusive
- whether to treat theend
inclusive or exclusively- Returns:
- number of business days between the
start
andend
, inclusive andendInclusive
respectively.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_INTend
- end time; if null, return NULL_INT- Returns:
- number of non-business days between the
start
andend
, inclusive.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstart
andend
.- Parameters:
start
- start time; if null, return NULL_INTend
- end time; if null, return NULL_INTendInclusive
- whether to treat theend
inclusive or exclusively- Returns:
- number of non-business days between the
start
andend
, inclusive andendInclusive
respectively.
-
fractionOfStandardBusinessDay
default double fractionOfStandardBusinessDay()Returns the ratio of the current day's business day length and the standard business day length. For example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard length and will therefore return 1.0. A half day holiday will return 0.5.- Returns:
- ratio of the business day length and the standard business day length for the current day
- See Also:
-
fractionOfStandardBusinessDay
For the given date, returns the ratio of the business day length and the standard business day length. For example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard length and will therefore return 1.0. A half day holiday will return 0.5.- Parameters:
time
- time; if null, return 0- Returns:
- ratio of the business day length and the standard business day length for the date
- See Also:
-
fractionOfStandardBusinessDay
For the given date, returns the ratio of the business day length and the standard business day length. For example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard length and will therefore return 1.0. A half day holiday will return 0.5.- Parameters:
date
- date; if null, return 0- Returns:
- ratio of the business day length and the standard business day length for the date
- See Also:
-
fractionOfBusinessDayRemaining
Returns the fraction of the business day remaining after the given time.- Parameters:
time
- time- Returns:
- the fraction of the day left after
time
; NULL_DOUBLE if time is null
-
fractionOfBusinessDayComplete
Returns the fraction of the business day complete by the given time.- Parameters:
time
- time- Returns:
- the fraction of the day complete by
time
; NULL_DOUBLE if time is null
-
isLastBusinessDayOfMonth
Is the time on the last business day of the month with business time remaining?- Parameters:
time
- time- Returns:
- true if
time
is on the last business day of the month with business time remaining; false otherwise.
-
isLastBusinessDayOfMonth
default boolean isLastBusinessDayOfMonth()Is the current day the last business day of the month?- Returns:
- true if
date
is on the last business day of the month; false otherwise.
-
isLastBusinessDayOfMonth
Is the date the last business day of the month?- Parameters:
date
- date- Returns:
- true if
date
is on the last business day of the month; false otherwise.
-
isLastBusinessDayOfWeek
default boolean isLastBusinessDayOfWeek()Is the current day the last business day of the week?- Returns:
- true if
date
is on the last business day of the week; false otherwise.
-
isLastBusinessDayOfWeek
Is the time on the last business day of the week with business time remaining?- Parameters:
time
- time- Returns:
- true if
time
is on the last business day of the week with business time remaining; false otherwise.
-
isLastBusinessDayOfWeek
Is the date the last business day of the week?- Parameters:
date
- date- Returns:
- true if
date
is on the last business day of the week; false otherwise.
-
getBusinessDay
Deprecated.Gets the indicated business day.- Parameters:
time
- time- Returns:
- the corresponding BusinessSchedule of
time
; null if time is null
-
getBusinessDay
Deprecated.Gets the indicated business day.- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getBusinessDay
Deprecated.Gets the indicated business day.- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getBusinessSchedule
Gets the indicated business day's schedule.getBusinessSchedule(null)
returnsnull
.- Parameters:
time
- time- Returns:
- the corresponding BusinessSchedule of
time
; null if time is null
-
getBusinessSchedule
Gets the indicated business day's schedule.getBusinessSchedule(null)
returnsnull
.- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getBusinessSchedule
Gets the indicated business day's schedule.getBusinessSchedule(null)
returnsnull
.- Parameters:
date
- date- Returns:
- the corresponding BusinessSchedule of
date
-
getLastHoliday
Gets the date of the last holiday defined in the calendar.- Returns:
- the date of the last holiday, or
LocalDate.MAX
if no holiday dates are defined
-