Interface Calendar

All Known Subinterfaces:
BusinessCalendar
All Known Implementing Classes:
AbstractBusinessCalendar, AbstractCalendar, DefaultBusinessCalendar, DefaultNoHolidayBusinessCalendar

public interface Calendar
A calendar. To comply with the ISO-8601 standard for Dates, Strings should be of the form "yyyy-MM-dd", Methods on DBDateTime may not be precisely defined enough to return a DBDateTime, e.g nextDay(). In these cases, the method will return a String as discussed above. To maintain consistency, each calendar has two fields: a name, and a time zone. A calendar with the same schedule but a different time zone is considered a different calendar. Frequently, the default implementation for methods on DBDateTimes is to call the corresponding method on a String with DBDateTime.toDateString. This can be slower than methods written explicitly for DBDateTimes. If performance is an issue, consider overriding these methods with other behavior.
  • Method Details

    • name

      String name()
      Gets the name of the calendar.
      Returns:
      the name of the calendar
    • currentDay

      default String currentDay()
      Gets the current date.
      Returns:
      the current day
    • previousDay

      default String previousDay()
      Gets yesterday's date.
      Returns:
      the date before the current day
    • previousDay

      default String previousDay(int days)
      Gets the date the specified number of days prior to the current day.
      Parameters:
      days - number of days;
      Returns:
      the date days before the current day
    • previousDay

      String previousDay(DBDateTime time)
      Gets the previous date.
      Parameters:
      time - time; if null, return null
      Returns:
      the day before time
    • previousDay

      String previousDay(DBDateTime time, int days)
      Gets the date the specified number of days prior to the input date.
      Parameters:
      time - time; if null, return null
      days - number of days;
      Returns:
      the date days before date
    • previousDay

      String previousDay(String date)
      Gets the previous date.
      Parameters:
      date - date; if null, return null
      Returns:
      the date before date
    • previousDay

      String previousDay(String date, int days)
      Gets the date the specified number of days prior to the input date.
      Parameters:
      date - date; if null, return null
      days - number of days;
      Returns:
      the date days before date
    • nextDay

      default String nextDay()
      Gets tomorrow's date.
      Returns:
      the date after the current day
    • nextDay

      default String nextDay(int days)
      Gets the date days after the current day.
      Parameters:
      days - number of days;
      Returns:
      the day after the current day
    • nextDay

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

      String nextDay(DBDateTime time, int days)
      Gets the date days after the input time.
      Parameters:
      time - time; if null, return null
      days - number of days;
      Returns:
      the day after time
    • nextDay

      String nextDay(String date)
      Gets the next date.
      Parameters:
      date - date; if null, return null
      Returns:
      the date after time
    • nextDay

      String nextDay(String date, int days)
      Gets the date days after the input date.
      Parameters:
      date - time; if null, return null
      days - number of days;
      Returns:
      the day after time
    • daysInRange

      String[] daysInRange(DBDateTime start, DBDateTime end)
      Gets the days in a given range.
      Parameters:
      start - start of a time range; if null, return empty array
      end - end of a time range; if null, return empty array
      Returns:
      the inclusive days between start and end
    • daysInRange

      String[] daysInRange(String start, String end)
      Gets the days in a given range.
      Parameters:
      start - start of a time range; if null, return empty array
      end - end of a time range; if null, return empty array
      Returns:
      the inclusive days between start and end
    • numberOfDays

      int numberOfDays(DBDateTime start, DBDateTime end)
      Gets the number of days in a given range, end date exclusive.
      Parameters:
      start - start of a time range; if null, return NULL_INT
      end - end of a time range; if null, return NULL_INT
      Returns:
      the number days between start and end, inclusive and exclusive respectively.
    • numberOfDays

      int numberOfDays(DBDateTime start, DBDateTime end, boolean endInclusive)
      Gets the number of days in a given range.
      Parameters:
      start - start of a time range; if null, return NULL_INT
      end - end of a time range; if null, return NULL_INT
      endInclusive - whether to treat the end inclusive or exclusively
      Returns:
      the number of days between start and end, inclusive and endInclusive respectively.
    • numberOfDays

      int numberOfDays(String start, String end)
      Gets the number of days in a given range, end date exclusive.
      Parameters:
      start - start of a time range; if null, return NULL_INT
      end - end of a time range; if null, return NULL_INT
      Returns:
      the number of days between start and end, inclusive and exclusive respectively.
    • numberOfDays

      int numberOfDays(String start, String end, boolean endInclusive)
      Gets the number of days in a given range.
      Parameters:
      start - start of a time range; if null, return NULL_INT
      end - end of a time range; if null, return NULL_INT
      endInclusive - whether to treat the end inclusive or exclusively
      Returns:
      the number of days between start and end, inclusive and endInclusive respectively.
    • diffNanos

      long diffNanos(DBDateTime start, DBDateTime end)
      Returns the amount of 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 time in nanoseconds between the start and end
    • diffDay

      double diffDay(DBDateTime start, DBDateTime end)
      Returns the amount of time in 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 time in days between the start and end
    • diffYear

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

      default DayOfWeek dayOfWeek()
      Gets the day of the week for the current day.
      Returns:
      the day of the week of the current day
    • dayOfWeek

      DayOfWeek dayOfWeek(DBDateTime time)
      Gets the day of the week for a time.
      Parameters:
      time - time; if null, return null
      Returns:
      the day of the week of time
    • dayOfWeek

      DayOfWeek dayOfWeek(String date)
      Gets the day of the week for a time.
      Parameters:
      date - date; if null, return null
      Returns:
      the day of the week of date
    • timeZone

      DBTimeZone timeZone()
      Gets the timezone of the calendar.
      Returns:
      the time zone of the calendar