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 betweenstartandend, inclusive.String[]businessDaysInRange(String start, String end) Returns the business days betweenstartandend, inclusive.default BusinessScheduleGets today's business schedule.doublediffBusinessDay(DBDateTime start, DBDateTime end) Returns the amount of business time in standard business days betweenstartandend.longdiffBusinessNanos(DBDateTime start, DBDateTime end) Returns the amount of business time in nanoseconds betweenstartandend.doublediffBusinessYear(DBDateTime start, DBDateTime end) Returns the number of business years betweenstartandend.doublediffNonBusinessDay(DBDateTime start, DBDateTime end) Returns the amount of non-business time in standard business days betweenstartandend.longdiffNonBusinessNanos(DBDateTime start, DBDateTime end) Returns the amount of non-business time in nanoseconds betweenstartandend.doubleReturns the fraction of the business day complete by the given time.doubleReturns the fraction of the business day remaining after the given time.default doubleReturns the ratio of the current day's business day length and the standard business day length.doubleFor the given date, returns the ratio of the business day length and the standard business day length.doubleFor 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 LocalDateGets the date of the last holiday defined in the calendar.byte[]For use in the web API server, so we can get the raw calendar data for shipping to clients.default booleanIs the current day a business day?booleanisBusinessDay(DBDateTime time) Does time occur on a business day?booleanisBusinessDay(String date) Is the date a business day?booleanisBusinessDay(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.booleanisBusinessDay(LocalDate date) Is the date a business day?booleanisBusinessTime(DBDateTime time) Determines if the specified time is a business time.default booleanIs the current day the last business day of the month?booleanIs the time on the last business day of the month with business time remaining?booleanIs the date the last business day of the month?default booleanIs the current day the last business day of the week?booleanIs the time on the last business day of the week with business time remaining?booleanIs the date the last business day of the week?default StringGets the next business day.default StringnextBusinessDay(int days) Gets the business datedaysbusiness days after the current day.nextBusinessDay(DBDateTime time) Gets the next business day.nextBusinessDay(DBDateTime time, int days) Gets the business datedaysbusiness days after inputtime.nextBusinessDay(String date) Gets the next business day.nextBusinessDay(String date, int days) Gets the business datedaysbusiness days after inputdate.default BusinessScheduleGets the next business schedule.default BusinessSchedulenextBusinessSchedule(int days) Gets the business scheduledaysdays after the current day.Gets the next business schedule.nextBusinessSchedule(DBDateTime time, int days) Gets the business scheduledaysdays after inputtime.nextBusinessSchedule(String date) Gets the next business schedule after inputdate.nextBusinessSchedule(String date, int days) Gets the business scheduledaysdays after inputdate.default StringGets the next non-business day.default StringnextNonBusinessDay(int days) Gets the non-business datedaysnon-business days after the current day.nextNonBusinessDay(DBDateTime time) Gets the next non-business day.nextNonBusinessDay(DBDateTime time, int days) Gets the non-business datedaysnon-business days after inputtime.nextNonBusinessDay(String date) Gets the next non-business day.nextNonBusinessDay(String date, int days) Gets the non-business datedaysnon-business days after inputdate.String[]nonBusinessDaysInRange(DBDateTime start, DBDateTime end) Returns the non-business days betweenstartandend, inclusive.String[]nonBusinessDaysInRange(String start, String end) Returns the non-business days betweenstartandend, inclusive.intnumberOfBusinessDays(DBDateTime start, DBDateTime end) Returns the number of business days betweenstartandend.intnumberOfBusinessDays(DBDateTime start, DBDateTime end, boolean endInclusive) Returns the number of business days betweenstartandend.intnumberOfBusinessDays(String start, String end) Returns the number of business days betweenstartandend.intnumberOfBusinessDays(String start, String end, boolean endInclusive) Returns the number of business days betweenstartandend.intnumberOfNonBusinessDays(DBDateTime start, DBDateTime end) Returns the number of non-business days betweenstartandend.intnumberOfNonBusinessDays(DBDateTime start, DBDateTime end, boolean endInclusive) Returns the number of non-business days betweenstartandend.intnumberOfNonBusinessDays(String start, String end) Returns the number of non-business days betweenstartandend.intnumberOfNonBusinessDays(String start, String end, boolean endInclusive) Returns the number of non-business days betweenstartandend.default StringGets the previous business day.default StringpreviousBusinessDay(int days) Gets the business datedaysbusiness days before the current day.Gets the previous business day.previousBusinessDay(DBDateTime time, int days) Gets the business datedaysbusiness days before inputtime.previousBusinessDay(String date) Gets the previous business day.previousBusinessDay(String date, int days) Gets the business datedaysbusiness days before inputdate.default BusinessScheduleGets the previous business schedule.default BusinessSchedulepreviousBusinessSchedule(int days) Gets the business scheduledaysdays before the current day.Gets the previous business schedule before inputtime.previousBusinessSchedule(DBDateTime time, int days) Gets the business scheduledaysdays before inputtime.Gets the business schedule before inputdate.previousBusinessSchedule(String date, int days) Gets the business scheduledaysdays before inputdate.default StringGets the previous non-business day.default StringpreviousNonBusinessDay(int days) Gets the non-business datedaysnon-business days before the current day.Gets the previous non-business day.previousNonBusinessDay(DBDateTime time, int days) Gets the non-business datedaysnon-business days before inputtime.previousNonBusinessDay(String date) Gets the previous non-business day.previousNonBusinessDay(String date, int days) Gets the non-business datedaysnon-business days before inputdate.longReturns 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 datedaysbusiness days before the current day. Ifdaysis zero and today is not a business day, null is returned.- Parameters:
days- number of days- Returns:
- the business date
daysbusiness 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 datedaysbusiness days before inputtime. Ifdaysis 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
daysbusiness 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 datedaysbusiness days before inputdate. Ifdaysis 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
daysbusiness days before inputdate
-
previousBusinessSchedule
Gets the previous business schedule.- Returns:
- previous business schedule
-
previousBusinessSchedule
Gets the business scheduledaysdays before the current day. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
days- number of days- Returns:
- the business schedule
daysdays 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 scheduledaysdays 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 scheduledaysdays before inputdate. Assumes implementation of getBusinessSchedule(null) returns null.- Parameters:
date- date; if null, return nulldays- number of days- Returns:
- the business schedule
daysdays 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 datedaysnon-business days before the current day. Ifdaysis zero and the day is a business day, null is returned.- Parameters:
days- number of days- Returns:
- the non-business date
daysnon-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 datedaysnon-business days before inputtime. Ifdaysis 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
daysnon-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 datedaysnon-business days before inputdate. Ifdaysis 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
daysnon-business days before inputdate
-
nextBusinessDay
Gets the next business day.- Returns:
- next business day
-
nextBusinessDay
Gets the business datedaysbusiness days after the current day. Ifdaysis zero and today is not a business day, null is returned.- Parameters:
days- number of days- Returns:
- the business date
daysbusiness 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 datedaysbusiness days after inputtime. Ifdaysis 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 datedaysbusiness days after inputdate. Ifdaysis 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
daysbusiness days after inputdate
-
nextBusinessSchedule
Gets the next business schedule.- Returns:
- next business schedule
-
nextBusinessSchedule
Gets the business scheduledaysdays 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 scheduledaysdays after inputtime. Ifdateis null, assumes the implementation of getBusinessSchedule(null) returns null.- Parameters:
time- time; if null, return nulldays- number of days- Returns:
- the business schedule
daysaftertime
-
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 scheduledaysdays after inputdate. Ifdateis null, assumes the implementation of getBusinessSchedule(null) returns null.- Parameters:
date- date; if null, return nulldays- number of days- Returns:
- the business schedule
daysafterdate
-
nextNonBusinessDay
Gets the next non-business day.- Returns:
- the next non-business day after the current day
-
nextNonBusinessDay
Gets the non-business datedaysnon-business days after the current day. Ifdaysis zero and the day is a business day, null is returned.- Parameters:
days- number of days- Returns:
- the non-business date
daysnon-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 datedaysnon-business days after inputtime. Ifdaysis 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
daysnon-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 datedaysnon-business days after inputdate. Ifdaysis 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 betweenstartandend, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstartandendwill 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
startandend
-
businessDaysInRange
Returns the business days betweenstartandend, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstartandendwill 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
startandend
-
nonBusinessDaysInRange
Returns the non-business days betweenstartandend, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstartandendwill 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
startandend
-
nonBusinessDaysInRange
Returns the non-business days betweenstartandend, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days forstartandendwill 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
startandend
-
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 betweenstartandend.- 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
startandend
-
diffNonBusinessNanos
Returns the amount of non-business time in nanoseconds betweenstartandend.- 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
startandend
-
diffBusinessDay
Returns the amount of business time in standard business days betweenstartandend.- 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
startandend
-
diffNonBusinessDay
Returns the amount of non-business time in standard business days betweenstartandend.- 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
startandend
-
diffBusinessYear
Returns the number of business years betweenstartandend.- Parameters:
start- start; if null, return nullend- end; if null, return null- Returns:
- the amount of business time in business years between the
startandend
-
numberOfBusinessDays
Returns the number of business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_INTend- end time; if null, return NULL_INT- Returns:
- number of business days between the
startandend, inclusive and exclusive respectively.
-
numberOfBusinessDays
Returns the number of business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_LONGend- end time; if null, return NULL_LONGendInclusive- whether to treat theendinclusive or exclusively- Returns:
- number of business days between the
startandend, inclusive andendInclusiverespectively.
-
numberOfBusinessDays
Returns the number of business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_INTend- end time; if null, return NULL_INT- Returns:
- number of business days between the
startandend, inclusive and exclusive respectively.
-
numberOfBusinessDays
Returns the number of business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_INTend- end time; if null, return NULL_INTendInclusive- whether to treat theendinclusive or exclusively- Returns:
- number of business days between the
startandend, inclusive andendInclusiverespectively.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_INTend- end time; if null, return NULL_INT- Returns:
- number of business days between the
startandend, inclusive and exclusive respectively.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_LONGend- end time; if null, return NULL_LONGendInclusive- whether to treat theendinclusive or exclusively- Returns:
- number of business days between the
startandend, inclusive andendInclusiverespectively.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_INTend- end time; if null, return NULL_INT- Returns:
- number of non-business days between the
startandend, inclusive.
-
numberOfNonBusinessDays
Returns the number of non-business days betweenstartandend.- Parameters:
start- start time; if null, return NULL_INTend- end time; if null, return NULL_INTendInclusive- whether to treat theendinclusive or exclusively- Returns:
- number of non-business days between the
startandend, inclusive andendInclusiverespectively.
-
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
timeis 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
dateis 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
dateis 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
dateis 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
timeis 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
dateis 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.MAXif no holiday dates are defined
-
getRawData
@NotNull byte[] getRawData()For use in the web API server, so we can get the raw calendar data for shipping to clients.- Returns:
- the raw data used to construct this calendar, may be null if the raw data is not available
- Throws:
IllegalArgumentException- if the calendar was constructed without raw data
-