Interface BusinessCalendar

All Superinterfaces:
Calendar
All Known Implementing Classes:
AbstractBusinessCalendar, DefaultBusinessCalendar, DefaultNoHolidayBusinessCalendar

public interface BusinessCalendar
extends Calendar
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 Details

    • getDefaultBusinessPeriods

      List<String> 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

      default BusinessSchedule 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

      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.
      Parameters:
      day - a day of the week
      Returns:
      true if the day is a business day; false otherwise.
    • isBusinessDay

      boolean isBusinessDay​(DBDateTime time)
      Does time occur on a business day?
      Parameters:
      time - time
      Returns:
      true if the date is a business day; false otherwise.
    • isBusinessDay

      boolean isBusinessDay​(String date)
      Is the date a business day?
      Parameters:
      date - date
      Returns:
      true if the date is a business day; false otherwise.
    • isBusinessDay

      boolean isBusinessDay​(LocalDate date)
      Is the date a business day?
      Parameters:
      date - date
      Returns:
      true if the date is a business day; false otherwise.
    • isBusinessTime

      boolean isBusinessTime​(DBDateTime time)
      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

      default String previousBusinessDay()
      Gets the previous business day.
      Returns:
      previous business day
    • previousBusinessDay

      default String previousBusinessDay​(int days)
      Gets the business date days business days before the current day. If days 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

      String previousBusinessDay​(DBDateTime time)
      Gets the previous business day.
      Parameters:
      time - time; if null, return null
      Returns:
      the most recent business day before time
    • previousBusinessDay

      String previousBusinessDay​(DBDateTime time, int days)
      Gets the business date days business days before input time. If days is zero and the day is not a business day, null is returned.
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the business date days business days before input time
    • previousBusinessDay

      String previousBusinessDay​(String date)
      Gets the previous business day.
      Parameters:
      date - date; if null, return null
      Returns:
      the most recent business day before date
    • previousBusinessDay

      String previousBusinessDay​(String date, int days)
      Gets the business date days business days before input date. If days is zero and the day is not a business day, null is returned.
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business date days business days before input date
    • previousBusinessSchedule

      default BusinessSchedule previousBusinessSchedule()
      Gets the previous business schedule.
      Returns:
      previous business schedule
    • previousBusinessSchedule

      default BusinessSchedule previousBusinessSchedule​(int days)
      Gets the business schedule days 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

      BusinessSchedule previousBusinessSchedule​(DBDateTime time)
      Gets the previous business schedule before input time. Assumes implementation of getBusinessSchedule(null) returns null.
      Parameters:
      time - time; if null, return null
      Returns:
      the most recent business schedule before time
    • previousBusinessSchedule

      BusinessSchedule previousBusinessSchedule​(DBDateTime time, int days)
      Gets the business schedule days days before input time. Assumes implementation of getBusinessSchedule(null) returns null.
      Parameters:
      time - time; if null, return null
      days - number of days
    • previousBusinessSchedule

      BusinessSchedule previousBusinessSchedule​(String date)
      Gets the business schedule before input date. Assumes implementation of getBusinessSchedule(null) returns null.
      Parameters:
      date - date; if null, return null
      Returns:
      the most recent business schedule before date
    • previousBusinessSchedule

      BusinessSchedule previousBusinessSchedule​(String date, int days)
      Gets the business schedule days days before input date. Assumes implementation of getBusinessSchedule(null) returns null.
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business schedule days days before input date
    • previousNonBusinessDay

      default String previousNonBusinessDay()
      Gets the previous non-business day.
      Returns:
      the most recent non-business day before the current day
    • previousNonBusinessDay

      default String previousNonBusinessDay​(int days)
      Gets the non-business date days non-business days before the current day. If days 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

      String previousNonBusinessDay​(DBDateTime time)
      Gets the previous non-business day.
      Parameters:
      time - time; if null, return null
      Returns:
      the most recent non-business day before time
    • previousNonBusinessDay

      String previousNonBusinessDay​(DBDateTime time, int days)
      Gets the non-business date days non-business days before input time. If days is zero and the day is a business day, null is returned.
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the non-business date days non-business days before input time
    • previousNonBusinessDay

      String previousNonBusinessDay​(String date)
      Gets the previous non-business day.
      Parameters:
      date - date; if null, return null
      Returns:
      the most recent non-business day before date
    • previousNonBusinessDay

      String previousNonBusinessDay​(String date, int days)
      Gets the non-business date days non-business days before input date. If days is zero and the day is a business day, null is returned.
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the non-business date days non-business days before input date
    • nextBusinessDay

      default String nextBusinessDay()
      Gets the next business day.
      Returns:
      next business day
    • nextBusinessDay

      default String nextBusinessDay​(int days)
      Gets the business date days business days after the current day. If days 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

      String nextBusinessDay​(DBDateTime time)
      Gets the next business day.
      Parameters:
      time - time; if null, return null
      Returns:
      the next business day after time
    • nextBusinessDay

      String nextBusinessDay​(DBDateTime time, int days)
      Gets the business date days business days after input time. If days is zero and the day is not a business day, null is returned.
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the next business day after time
    • nextBusinessDay

      String nextBusinessDay​(String date)
      Gets the next business day.
      Parameters:
      date - date; if null, return null
      Returns:
      the next business day after date
    • nextBusinessDay

      String nextBusinessDay​(String date, int days)
      Gets the business date days business days after input date. If days is zero and the day is not a business day, null is returned.
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business date days business days after input date
    • nextBusinessSchedule

      default BusinessSchedule nextBusinessSchedule()
      Gets the next business schedule.
      Returns:
      next business schedule
    • nextBusinessSchedule

      default BusinessSchedule nextBusinessSchedule​(int days)
      Gets the business schedule days 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

      BusinessSchedule nextBusinessSchedule​(DBDateTime time)
      Gets the next business schedule.
      Parameters:
      time - time; if null, return null
      Returns:
      the next closest business schedule after time
    • nextBusinessSchedule

      BusinessSchedule nextBusinessSchedule​(DBDateTime time, int days)
      Gets the business schedule days days after input time. If date is null, assumes the implementation of getBusinessSchedule(null) returns null.
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the business schedule days after time
    • nextBusinessSchedule

      BusinessSchedule nextBusinessSchedule​(String date)
      Gets the next business schedule after input date. Assumes implementation of getBusinessSchedule(null) returns null.
      Parameters:
      date - date; if null, return null
      Returns:
      the next closest business schedule after date
    • nextBusinessSchedule

      BusinessSchedule nextBusinessSchedule​(String date, int days)
      Gets the business schedule days days after input date. If date is null, assumes the implementation of getBusinessSchedule(null) returns null.
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business schedule days after date
    • nextNonBusinessDay

      default String nextNonBusinessDay()
      Gets the next non-business day.
      Returns:
      the next non-business day after the current day
    • nextNonBusinessDay

      default String nextNonBusinessDay​(int days)
      Gets the non-business date days non-business days after the current day. If days 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

      String nextNonBusinessDay​(DBDateTime time)
      Gets the next non-business day.
      Parameters:
      time - time; if null, return null
      Returns:
      the next non-business day after time
    • nextNonBusinessDay

      String nextNonBusinessDay​(DBDateTime time, int days)
      Gets the non-business date days non-business days after input time. If days is zero and the day is a business day, null is returned.
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the non-business date days non-business days after input time
    • nextNonBusinessDay

      String nextNonBusinessDay​(String date)
      Gets the next non-business day.
      Parameters:
      date - date; if null, return null
      Returns:
      the next non-business day after date
    • nextNonBusinessDay

      String nextNonBusinessDay​(String date, int days)
      Gets the non-business date days non-business days after input date. If days is zero and the day is a business day, null is returned.
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the most recent business day before time
    • businessDaysInRange

      String[] businessDaysInRange​(DBDateTime start, DBDateTime end)
      Returns the business days between start and end, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for start and end will be included if they are business days.
      Parameters:
      start - start time; if null, return empty array
      end - end time; if null, return empty array
      Returns:
      inclusive business days between start and end
    • businessDaysInRange

      String[] businessDaysInRange​(String start, String end)
      Returns the business days between start and end, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for start and end will be included if they are business days.
      Parameters:
      start - start time; if null, return empty array
      end - end time; if null, return empty array
      Returns:
      inclusive business days between start and end
    • nonBusinessDaysInRange

      String[] nonBusinessDaysInRange​(DBDateTime start, DBDateTime end)
      Returns the non-business days between start and end, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for start and end will be included if they are non-business days.
      Parameters:
      start - start time; if null, return empty array
      end - end time; if null, return empty array
      Returns:
      inclusive non-business days between start and end
    • nonBusinessDaysInRange

      String[] nonBusinessDaysInRange​(String start, String end)
      Returns the non-business days between start and end, inclusive. Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for start and end will be included if they are non-business days.
      Parameters:
      start - start time; if null, return empty array
      end - end time; if null, return empty array
      Returns:
      inclusive non-business days between start and end
    • standardBusinessDayLengthNanos

      long standardBusinessDayLengthNanos()
      Returns the length of a standard business day in nanoseconds.
      Returns:
      length of a standard business day in nanoseconds.
    • diffBusinessNanos

      long diffBusinessNanos​(DBDateTime start, DBDateTime end)
      Returns the amount of business time in nanoseconds between start and end.
      Parameters:
      start - start time; if null, return NULL_LONG
      end - end time; if null, return NULL_LONG
      Returns:
      the amount of business time in nanoseconds between the start and end
    • diffNonBusinessNanos

      long diffNonBusinessNanos​(DBDateTime start, DBDateTime end)
      Returns the amount of non-business time in nanoseconds between start and end.
      Parameters:
      start - start time; if null, return NULL_LONG
      end - end time; if null, return NULL_LONG
      Returns:
      the amount of non-business time in nanoseconds between the start and end
    • diffBusinessDay

      double diffBusinessDay​(DBDateTime start, DBDateTime end)
      Returns the amount of business time in standard business days between start and end.
      Parameters:
      start - start time; if null, return NULL_LONG
      end - end time; if null, return NULL_LONG
      Returns:
      the amount of business time in standard business days between the start and end
    • diffNonBusinessDay

      double diffNonBusinessDay​(DBDateTime start, DBDateTime end)
      Returns the amount of non-business time in standard business days between start and end.
      Parameters:
      start - start time; if null, return NULL_LONG
      end - end time; if null, return NULL_LONG
      Returns:
      the amount of non-business time in standard business days between the start and end
    • diffBusinessYear

      double diffBusinessYear​(DBDateTime start, DBDateTime end)
      Returns the number of business years between start and end.
      Parameters:
      start - start; if null, return null
      end - end; if null, return null
      Returns:
      the amount of business time in business years between the start and end
    • numberOfBusinessDays

      int numberOfBusinessDays​(DBDateTime start, DBDateTime end)
      Returns the number of business days between start and end.
      Parameters:
      start - start time; if null, return NULL_INT
      end - end time; if null, return NULL_INT
      Returns:
      number of business days between the start and end, inclusive and exclusive respectively.
    • numberOfBusinessDays

      int numberOfBusinessDays​(DBDateTime start, DBDateTime end, boolean endInclusive)
      Returns the number of business days between start and end.
      Parameters:
      start - start time; if null, return NULL_LONG
      end - end time; if null, return NULL_LONG
      endInclusive - whether to treat the end inclusive or exclusively
      Returns:
      number of business days between the start and end, inclusive and endInclusive respectively.
    • numberOfBusinessDays

      int numberOfBusinessDays​(String start, String end)
      Returns the number of business days between start and end.
      Parameters:
      start - start time; if null, return NULL_INT
      end - end time; if null, return NULL_INT
      Returns:
      number of business days between the start and end, inclusive and exclusive respectively.
    • numberOfBusinessDays

      int numberOfBusinessDays​(String start, String end, boolean endInclusive)
      Returns the number of business days between start and end.
      Parameters:
      start - start time; if null, return NULL_INT
      end - end time; if null, return NULL_INT
      endInclusive - whether to treat the end inclusive or exclusively
      Returns:
      number of business days between the start and end, inclusive and endInclusive respectively.
    • numberOfNonBusinessDays

      int numberOfNonBusinessDays​(DBDateTime start, DBDateTime end)
      Returns the number of non-business days between start and end.
      Parameters:
      start - start time; if null, return NULL_INT
      end - end time; if null, return NULL_INT
      Returns:
      number of business days between the start and end, inclusive and exclusive respectively.
    • numberOfNonBusinessDays

      int numberOfNonBusinessDays​(DBDateTime start, DBDateTime end, boolean endInclusive)
      Returns the number of non-business days between start and end.
      Parameters:
      start - start time; if null, return NULL_LONG
      end - end time; if null, return NULL_LONG
      endInclusive - whether to treat the end inclusive or exclusively
      Returns:
      number of business days between the start and end, inclusive and endInclusive respectively.
    • numberOfNonBusinessDays

      int numberOfNonBusinessDays​(String start, String end)
      Returns the number of non-business days between start and end.
      Parameters:
      start - start time; if null, return NULL_INT
      end - end time; if null, return NULL_INT
      Returns:
      number of non-business days between the start and end, inclusive.
    • numberOfNonBusinessDays

      int numberOfNonBusinessDays​(String start, String end, boolean endInclusive)
      Returns the number of non-business days between start and end.
      Parameters:
      start - start time; if null, return NULL_INT
      end - end time; if null, return NULL_INT
      endInclusive - whether to treat the end inclusive or exclusively
      Returns:
      number of non-business days between the start and end, inclusive and endInclusive 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:
      fractionOfBusinessDayRemaining(DBDateTime)
    • fractionOfStandardBusinessDay

      double fractionOfStandardBusinessDay​(DBDateTime time)
      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:
      fractionOfBusinessDayRemaining(DBDateTime)
    • fractionOfStandardBusinessDay

      double fractionOfStandardBusinessDay​(String date)
      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(DBDateTime)
    • fractionOfBusinessDayRemaining

      double fractionOfBusinessDayRemaining​(DBDateTime time)
      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

      double fractionOfBusinessDayComplete​(DBDateTime time)
      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

      boolean isLastBusinessDayOfMonth​(DBDateTime time)
      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

      boolean isLastBusinessDayOfMonth​(String date)
      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

      boolean isLastBusinessDayOfWeek​(DBDateTime time)
      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

      boolean isLastBusinessDayOfWeek​(String date)
      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 BusinessSchedule getBusinessDay​(DBDateTime time)
      Deprecated.
      Gets the indicated business day.
      Parameters:
      time - time
      Returns:
      the corresponding BusinessSchedule of time; null if time is null
    • getBusinessDay

      @Deprecated BusinessSchedule getBusinessDay​(String date)
      Deprecated.
      Gets the indicated business day.
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getBusinessDay

      @Deprecated BusinessSchedule getBusinessDay​(LocalDate date)
      Deprecated.
      Gets the indicated business day.
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getBusinessSchedule

      BusinessSchedule getBusinessSchedule​(DBDateTime time)
      Gets the indicated business day's schedule. getBusinessSchedule(null) returns null.
      Parameters:
      time - time
      Returns:
      the corresponding BusinessSchedule of time; null if time is null
    • getBusinessSchedule

      BusinessSchedule getBusinessSchedule​(String date)
      Gets the indicated business day's schedule. getBusinessSchedule(null) returns null.
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getBusinessSchedule

      BusinessSchedule getBusinessSchedule​(LocalDate date)
      Gets the indicated business day's schedule. getBusinessSchedule(null) returns null.
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getLastHoliday

      default LocalDate 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