Class DateRange

All Implemented Interfaces:
Serializable, Comparable<ComparableRange<Date>>, Range<Date>

public class DateRange extends ComparableRange<Date> implements Serializable
An immutable range of dates. This class is here for backward compatibility - new code should use ComparableRange<Date> instead.
See Also:
  • Field Details

    • MIN_DATE

      public static final Date MIN_DATE
      A Date instance initialized to the earliest possible date.
    • MAX_DATE

      public static final Date MAX_DATE
      A Date instance initialized to the latest possible date.
    • FULL_RANGE

      public static final DateRange FULL_RANGE
      A DateRange instance initialized to the widest possible range of dates.
  • Constructor Details

    • DateRange

      public DateRange(Date start, Date end)
      Parameters:
      start - If null, defaults to MIN_DATE
      end - If null, defaults to MAX_DATE
  • Method Details

    • timestampToDate

      protected static Date timestampToDate(Date date)
    • after

      public boolean after(Date date)
      Description copied from interface: Range
      Returns true if this range occurs after value.
      Specified by:
      after in interface Range<Date>
      Overrides:
      after in class ComparableRange<Date>
      Parameters:
      date - The value to test
      Returns:
      true if this range occurs after value
    • before

      public boolean before(Date date)
      Description copied from interface: Range
      Returns true if this range occurs before value.
      Specified by:
      before in interface Range<Date>
      Overrides:
      before in class ComparableRange<Date>
      Parameters:
      date - The value to test
      Returns:
      true if this range occurs before value
    • durationInMillis

      public long durationInMillis()
      Returns this range's duration as a millisecond value.
      Returns:
      Range duration in milliseconds
    • end

      public Date end()
      Description copied from interface: Range
      Returns the ending value of this range.
      Specified by:
      end in interface Range<Date>
      Overrides:
      end in class ComparableRange<Date>
      Returns:
      Ending value
    • endStamp

      public Timestamp endStamp()
      Returns the ending date of this range as a Timestamp instance.
      Returns:
      Range ending date Timestamp
    • includesDate

      public boolean includesDate(Date date)
      Returns true if date occurs within this range.
      Parameters:
      date -
      Returns:
      true if date occurs within this range
    • intersectsRange

      public boolean intersectsRange(Date start, Date end)
      Returns true if start and end intersect this range.
      Parameters:
      start - If null, defaults to MIN_DATE
      end - If null, defaults to MAX_DATE
      Returns:
      true if start and end intersect this range
    • intersectsRange

      public boolean intersectsRange(DateRange range)
      Returns true if range intersects this range.
      Parameters:
      range -
      Returns:
      true if range intersects this range
    • start

      public Date start()
      Description copied from interface: Range
      Returns the starting value of this range.
      Specified by:
      start in interface Range<Date>
      Overrides:
      start in class ComparableRange<Date>
      Returns:
      Starting value
    • startStamp

      public Timestamp startStamp()
      Returns the starting date of this range as a Timestamp instance.
      Returns:
      Range starting date Timestamp