Class CalendarDay<T extends Comparable<T> & Temporal>

java.lang.Object
io.deephaven.time.calendar.CalendarDay<T>
Type Parameters:
T - time type

public class CalendarDay<T extends Comparable<T> & Temporal> extends Object
Schedule for a single calendar day. The schedule contains a list of business time ranges, which are the ranges of time during which businesses are open.

A business day may contain multiple business time ranges. For example, some financial exchanges have a morning and an afternoon trading session. This would be represented by a business day with two business time ranges.

  • Field Details

    • HOLIDAY

      public static final CalendarDay<LocalTime> HOLIDAY
      A holiday with no business time ranges.
  • Method Details

    • businessTimeRanges

      public List<TimeRange<T>> businessTimeRanges()
      Business time ranges for the day.
      Returns:
      business time ranges for the day
    • businessStart

      public T businessStart()
      Start of the business day. Equivalent to the start of the first business time range.
      Returns:
      start of the business day, or null for a holiday schedule
    • businessEnd

      public T businessEnd()
      End of the business day. Equivalent to the end of the last business time range.
      Returns:
      end of the business day, or null for a holiday schedule
    • isInclusiveEnd

      public boolean isInclusiveEnd()
      Is the end of the business day inclusive? Equivalent to the end of the last business time range.
      Returns:
      is the end of the business day inclusive?
    • businessNanos

      public long businessNanos()
      Gets the length of the business day in nanoseconds. If the business day has multiple business time ranges, only the time during the ranges is counted.
      Returns:
      length of the day in nanoseconds
    • businessDuration

      public Duration businessDuration()
      Gets the length of the business day. If the business day has multiple business time ranges, only the time during the ranges is counted.
      Returns:
      length of the day
    • businessNanosElapsed

      public long businessNanosElapsed(T time)
      Amount of business time in nanoseconds that has elapsed on the given day by the specified time.
      Parameters:
      time - time
      Returns:
      business time in nanoseconds that has elapsed on the given day by the specified time, or QueryConstants.NULL_LONG if the input is null.
    • businessDurationElapsed

      public Duration businessDurationElapsed(T time)
      Amount of business time that has elapsed on the given day by the specified time.
      Parameters:
      time - time
      Returns:
      business time that has elapsed on the given day by the specified time, or null if the input is null.
    • businessNanosRemaining

      public long businessNanosRemaining(T time)
      Amount of business time in nanoseconds that remains until the end of the day.
      Parameters:
      time - time
      Returns:
      business time in nanoseconds that remains until the end of the day, or QueryConstants.NULL_LONG if the input is null.
    • businessDurationRemaining

      public Duration businessDurationRemaining(T time)
      Amount of business time that remains until the end of the day.
      Parameters:
      time - time
      Returns:
      business time that remains until the end of the day, or null if the input is null.
    • isBusinessDay

      public boolean isBusinessDay()
      Is this day a business day? A business day is a day that contains at least some business time.
      Returns:
      true if it is a business day; false otherwise.
    • isBusinessTime

      public boolean isBusinessTime(T time)
      Determines if the specified time is a business time for the day.
      Parameters:
      time - time.
      Returns:
      true if the time is a business time for the day; otherwise, false. If the input is null, returns false.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

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

      public static CalendarDay<Instant> toInstant(CalendarDay<LocalTime> s, LocalDate date, ZoneId timeZone)
      Converts a business schedule in local time to a specific date and time zone.
      Parameters:
      s - business schedule in local time
      date - date for the new business schedule
      timeZone - time zone for the new business schedule
      Returns:
      new business schedule in the specified date and time zone