Class DefaultBusinessCalendar

All Implemented Interfaces:
BusinessCalendar, Calendar, Serializable

public class DefaultBusinessCalendar extends AbstractBusinessCalendar implements Serializable
Default implementation for a BusinessCalendar. This implementation is thread safe. Overrides many default Calendar and BusinessCalendar methods for improved performance. See the documentation of Calendar for details.
See Also:
  • Method Details

    • getDefaultBusinessPeriods

      public List<String> getDefaultBusinessPeriods()
      Description copied from interface: BusinessCalendar
      Gets the business periods for the default days.
      Specified by:
      getDefaultBusinessPeriods in interface BusinessCalendar
      Returns:
      a list of strings with a comma separating open and close times
    • getHolidays

      public Map<LocalDate,BusinessSchedule> getHolidays()
      Description copied from interface: BusinessCalendar
      Gets business schedules for dates that are different from the defaults. This returns all dates that are defined as a holiday for the calendar.
      Specified by:
      getHolidays in interface BusinessCalendar
      Returns:
      a map of dates and to their business periods
    • isBusinessDay

      public boolean isBusinessDay(DayOfWeek day)
      Description copied from interface: BusinessCalendar
      Is the day of the week a business day? A business day is a day that has a business schedule with one or more business periods defined.
      Specified by:
      isBusinessDay in interface BusinessCalendar
      Parameters:
      day - a day of the week
      Returns:
      true if the day is a business day; false otherwise.
    • name

      public String name()
      Description copied from interface: Calendar
      Gets the name of the calendar.
      Specified by:
      name in interface Calendar
      Returns:
      the name of the calendar
    • timeZone

      public DBTimeZone timeZone()
      Description copied from interface: Calendar
      Gets the timezone of the calendar.
      Specified by:
      timeZone in interface Calendar
      Returns:
      the time zone of the calendar
    • standardBusinessDayLengthNanos

      public long standardBusinessDayLengthNanos()
      Description copied from interface: BusinessCalendar
      Returns the length of a standard business day in nanoseconds.
      Specified by:
      standardBusinessDayLengthNanos in interface BusinessCalendar
      Returns:
      length of a standard business day in nanoseconds.
    • getBusinessDay

      @Deprecated public BusinessSchedule getBusinessDay(DBDateTime time)
      Deprecated.
      Description copied from interface: BusinessCalendar
      Gets the indicated business day.
      Specified by:
      getBusinessDay in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      the corresponding BusinessSchedule of time; null if time is null
    • getBusinessDay

      @Deprecated public BusinessSchedule getBusinessDay(String date)
      Deprecated.
      Description copied from interface: BusinessCalendar
      Gets the indicated business day.
      Specified by:
      getBusinessDay in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getBusinessDay

      @Deprecated public BusinessSchedule getBusinessDay(LocalDate date)
      Deprecated.
      Description copied from interface: BusinessCalendar
      Gets the indicated business day.
      Specified by:
      getBusinessDay in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getBusinessSchedule

      public BusinessSchedule getBusinessSchedule(DBDateTime time)
      Description copied from interface: BusinessCalendar
      Gets the indicated business day's schedule. getBusinessSchedule(null) returns null.
      Specified by:
      getBusinessSchedule in interface BusinessCalendar
      Parameters:
      time - time
      Returns:
      the corresponding BusinessSchedule of time; null if time is null
    • getBusinessSchedule

      public BusinessSchedule getBusinessSchedule(String date)
      Description copied from interface: BusinessCalendar
      Gets the indicated business day's schedule. getBusinessSchedule(null) returns null.
      Specified by:
      getBusinessSchedule in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getBusinessSchedule

      public BusinessSchedule getBusinessSchedule(LocalDate date)
      Description copied from interface: BusinessCalendar
      Gets the indicated business day's schedule. getBusinessSchedule(null) returns null.
      Specified by:
      getBusinessSchedule in interface BusinessCalendar
      Parameters:
      date - date
      Returns:
      the corresponding BusinessSchedule of date
    • getLastHoliday

      public LocalDate getLastHoliday()
      Description copied from interface: BusinessCalendar
      Gets the date of the last holiday defined in the calendar.
      Specified by:
      getLastHoliday in interface BusinessCalendar
      Returns:
      the date of the last holiday, or LocalDate.MAX if no holiday dates are defined
    • diffBusinessNanos

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

      public double diffBusinessYear(DBDateTime startTime, DBDateTime endTime)
      Description copied from interface: BusinessCalendar
      Returns the number of business years between start and end.
      Specified by:
      diffBusinessYear in interface BusinessCalendar
      Parameters:
      startTime - start; if null, return null
      endTime - end; if null, return null
      Returns:
      the amount of business time in business years between the start and end
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getRawData

      @NotNull public byte[] getRawData()
      For use in the web API server, so we can get the raw calendar data for shipping to clients.
      Specified by:
      getRawData in interface BusinessCalendar
      Returns:
      the raw data used to construct this calendar, may be null if the raw data is not available
      Throws:
      IllegalArgumentException - if the
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object