Class AbstractBusinessCalendar

java.lang.Object
com.illumon.util.calendar.AbstractCalendar
com.illumon.util.calendar.AbstractBusinessCalendar
All Implemented Interfaces:
BusinessCalendar, Calendar
Direct Known Subclasses:
DefaultBusinessCalendar, DefaultNoHolidayBusinessCalendar

public abstract class AbstractBusinessCalendar extends AbstractCalendar implements BusinessCalendar
  • Constructor Details

    • AbstractBusinessCalendar

      public AbstractBusinessCalendar()
  • Method Details

    • isBusinessDay

      public boolean isBusinessDay(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Does time occur on a business day?
      Specified by:
      isBusinessDay in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      true if the date is a business day; false otherwise.
    • isBusinessDay

      public boolean isBusinessDay(String date)
      Description copied from interface: BusinessCalendar
      Is the date a business day?
      Specified by:
      isBusinessDay in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      true if the date is a business day; false otherwise.
    • isBusinessDay

      public boolean isBusinessDay(LocalDate date)
      Description copied from interface: BusinessCalendar
      Is the date a business day?
      Specified by:
      isBusinessDay in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      true if the date is a business day; false otherwise.
    • isBusinessTime

      public boolean isBusinessTime(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Determines if the specified time is a business time. If the time falls between business periods, false will be returned.
      Specified by:
      isBusinessTime in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      true if the specified time is a business time; otherwise, false.
    • previousBusinessDay

      public String previousBusinessDay(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the previous business day.
      Specified by:
      previousBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      Returns:
      the most recent business day before time
    • previousBusinessDay

      public String previousBusinessDay(DBDateTime time, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      previousBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the business date days business days before input time
    • previousBusinessDay

      public String previousBusinessDay(String date)
      Description copied from interface: BusinessCalendar
      Gets the previous business day.
      Specified by:
      previousBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      Returns:
      the most recent business day before date
    • previousBusinessDay

      public String previousBusinessDay(String date, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      previousBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business date days business days before input date
    • previousBusinessSchedule

      public BusinessSchedule previousBusinessSchedule(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the previous business schedule before input time. Assumes implementation of getBusinessSchedule(null) returns null.
      Specified by:
      previousBusinessSchedule in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      Returns:
      the most recent business schedule before time
    • previousBusinessSchedule

      public BusinessSchedule previousBusinessSchedule(DBDateTime time, int days)
      Description copied from interface: BusinessCalendar
      Gets the business schedule days days before input time. Assumes implementation of getBusinessSchedule(null) returns null.
      Specified by:
      previousBusinessSchedule in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      days - number of days
    • previousBusinessSchedule

      public BusinessSchedule previousBusinessSchedule(String date)
      Description copied from interface: BusinessCalendar
      Gets the business schedule before input date. Assumes implementation of getBusinessSchedule(null) returns null.
      Specified by:
      previousBusinessSchedule in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      Returns:
      the most recent business schedule before date
    • previousBusinessSchedule

      public BusinessSchedule previousBusinessSchedule(String date, int days)
      Description copied from interface: BusinessCalendar
      Gets the business schedule days days before input date. Assumes implementation of getBusinessSchedule(null) returns null.
      Specified by:
      previousBusinessSchedule in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business schedule days days before input date
    • previousNonBusinessDay

      public String previousNonBusinessDay(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the previous non-business day.
      Specified by:
      previousNonBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      Returns:
      the most recent non-business day before time
    • previousNonBusinessDay

      public String previousNonBusinessDay(DBDateTime time, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      previousNonBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the non-business date days non-business days before input time
    • previousNonBusinessDay

      public String previousNonBusinessDay(String date)
      Description copied from interface: BusinessCalendar
      Gets the previous non-business day.
      Specified by:
      previousNonBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      Returns:
      the most recent non-business day before date
    • previousNonBusinessDay

      public String previousNonBusinessDay(String date, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      previousNonBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the non-business date days non-business days before input date
    • nextBusinessDay

      public String nextBusinessDay(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the next business day.
      Specified by:
      nextBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      Returns:
      the next business day after time
    • nextBusinessDay

      public String nextBusinessDay(DBDateTime time, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      nextBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the next business day after time
    • nextBusinessDay

      public String nextBusinessDay(String date)
      Description copied from interface: BusinessCalendar
      Gets the next business day.
      Specified by:
      nextBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      Returns:
      the next business day after date
    • nextBusinessDay

      public String nextBusinessDay(String date, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      nextBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business date days business days after input date
    • nextBusinessSchedule

      public BusinessSchedule nextBusinessSchedule(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the next business schedule.
      Specified by:
      nextBusinessSchedule in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      Returns:
      the next closest business schedule after time
    • nextBusinessSchedule

      public BusinessSchedule nextBusinessSchedule(DBDateTime time, int days)
      Description copied from interface: BusinessCalendar
      Gets the business schedule days days after input time. If date is null, assumes the implementation of getBusinessSchedule(null) returns null.
      Specified by:
      nextBusinessSchedule in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the business schedule days after time
    • nextBusinessSchedule

      public BusinessSchedule nextBusinessSchedule(String date)
      Description copied from interface: BusinessCalendar
      Gets the next business schedule after input date. Assumes implementation of getBusinessSchedule(null) returns null.
      Specified by:
      nextBusinessSchedule in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      Returns:
      the next closest business schedule after date
    • nextBusinessSchedule

      public BusinessSchedule nextBusinessSchedule(String date, int days)
      Description copied from interface: BusinessCalendar
      Gets the business schedule days days after input date. If date is null, assumes the implementation of getBusinessSchedule(null) returns null.
      Specified by:
      nextBusinessSchedule in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the business schedule days after date
    • nextNonBusinessDay

      public String nextNonBusinessDay(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the next non-business day.
      Specified by:
      nextNonBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      Returns:
      the next non-business day after time
    • nextNonBusinessDay

      public String nextNonBusinessDay(DBDateTime time, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      nextNonBusinessDay in interface BusinessCalendar
      Parameters:
      time - time; if null, return null
      days - number of days
      Returns:
      the non-business date days non-business days after input time
    • nextNonBusinessDay

      public String nextNonBusinessDay(String date)
      Description copied from interface: BusinessCalendar
      Gets the next non-business day.
      Specified by:
      nextNonBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      Returns:
      the next non-business day after date
    • nextNonBusinessDay

      public String nextNonBusinessDay(String date, int days)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      nextNonBusinessDay in interface BusinessCalendar
      Parameters:
      date - date; if null, return null
      days - number of days
      Returns:
      the most recent business day before time
    • businessDaysInRange

      public String[] businessDaysInRange(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      businessDaysInRange in interface BusinessCalendar
      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

      public String[] businessDaysInRange(String start, String end)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      businessDaysInRange in interface BusinessCalendar
      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

      public String[] nonBusinessDaysInRange(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      nonBusinessDaysInRange in interface BusinessCalendar
      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

      public String[] nonBusinessDaysInRange(String start, String end)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      nonBusinessDaysInRange in interface BusinessCalendar
      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
    • diffNonBusinessNanos

      public long diffNonBusinessNanos(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      Returns the amount of non-business time in nanoseconds between start and end.
      Specified by:
      diffNonBusinessNanos in interface BusinessCalendar
      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

      public double diffBusinessDay(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      Returns the amount of business time in standard business days between start and end.
      Specified by:
      diffBusinessDay in interface BusinessCalendar
      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

      public double diffNonBusinessDay(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      Returns the amount of non-business time in standard business days between start and end.
      Specified by:
      diffNonBusinessDay in interface BusinessCalendar
      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
    • numberOfBusinessDays

      public int numberOfBusinessDays(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      Returns the number of business days between start and end.
      Specified by:
      numberOfBusinessDays in interface BusinessCalendar
      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

      public int numberOfBusinessDays(DBDateTime start, DBDateTime end, boolean endInclusive)
      Description copied from interface: BusinessCalendar
      Returns the number of business days between start and end.
      Specified by:
      numberOfBusinessDays in interface BusinessCalendar
      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

      public int numberOfBusinessDays(String start, String end)
      Description copied from interface: BusinessCalendar
      Returns the number of business days between start and end.
      Specified by:
      numberOfBusinessDays in interface BusinessCalendar
      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

      public int numberOfBusinessDays(String start, String end, boolean endInclusive)
      Description copied from interface: BusinessCalendar
      Returns the number of business days between start and end.
      Specified by:
      numberOfBusinessDays in interface BusinessCalendar
      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

      public int numberOfNonBusinessDays(DBDateTime start, DBDateTime end)
      Description copied from interface: BusinessCalendar
      Returns the number of non-business days between start and end.
      Specified by:
      numberOfNonBusinessDays in interface BusinessCalendar
      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

      public int numberOfNonBusinessDays(DBDateTime start, DBDateTime end, boolean endInclusive)
      Description copied from interface: BusinessCalendar
      Returns the number of non-business days between start and end.
      Specified by:
      numberOfNonBusinessDays in interface BusinessCalendar
      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

      public int numberOfNonBusinessDays(String start, String end)
      Description copied from interface: BusinessCalendar
      Returns the number of non-business days between start and end.
      Specified by:
      numberOfNonBusinessDays in interface BusinessCalendar
      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

      public int numberOfNonBusinessDays(String start, String end, boolean endInclusive)
      Description copied from interface: BusinessCalendar
      Returns the number of non-business days between start and end.
      Specified by:
      numberOfNonBusinessDays in interface BusinessCalendar
      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

      public double fractionOfStandardBusinessDay(DBDateTime time)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      fractionOfStandardBusinessDay in interface BusinessCalendar
      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

      public double fractionOfStandardBusinessDay(String date)
      Description copied from interface: BusinessCalendar
      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.
      Specified by:
      fractionOfStandardBusinessDay in interface BusinessCalendar
      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

      public double fractionOfBusinessDayRemaining(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Returns the fraction of the business day remaining after the given time.
      Specified by:
      fractionOfBusinessDayRemaining in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      the fraction of the day left after time; NULL_DOUBLE if time is null
    • fractionOfBusinessDayComplete

      public double fractionOfBusinessDayComplete(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Returns the fraction of the business day complete by the given time.
      Specified by:
      fractionOfBusinessDayComplete in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      the fraction of the day complete by time; NULL_DOUBLE if time is null
    • isLastBusinessDayOfMonth

      public boolean isLastBusinessDayOfMonth(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Is the time on the last business day of the month with business time remaining?
      Specified by:
      isLastBusinessDayOfMonth in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      true if time is on the last business day of the month with business time remaining; false otherwise.
    • isLastBusinessDayOfMonth

      public boolean isLastBusinessDayOfMonth(String date)
      Description copied from interface: BusinessCalendar
      Is the date the last business day of the month?
      Specified by:
      isLastBusinessDayOfMonth in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      true if date is on the last business day of the month; false otherwise.
    • isLastBusinessDayOfWeek

      public boolean isLastBusinessDayOfWeek(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Is the time on the last business day of the week with business time remaining?
      Specified by:
      isLastBusinessDayOfWeek in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      true if time is on the last business day of the week with business time remaining; false otherwise.
    • isLastBusinessDayOfWeek

      public boolean isLastBusinessDayOfWeek(String date)
      Description copied from interface: BusinessCalendar
      Is the date the last business day of the week?
      Specified by:
      isLastBusinessDayOfWeek in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      true if date is on the last business day of the week; false otherwise.