Class DateRange

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ComparableRange<java.util.Date>>, Range<java.util.Date>

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

      Fields 
      Modifier and Type Field Description
      static DateRange FULL_RANGE
      A DateRange instance initialized to the widest possible range of dates.
      static java.util.Date MAX_DATE
      A Date instance initialized to the latest possible date.
      static java.util.Date MIN_DATE
      A Date instance initialized to the earliest possible date.
    • Constructor Summary

      Constructors 
      Constructor Description
      DateRange​(java.util.Date start, java.util.Date end)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean after​(java.util.Date date)
      Returns true if this range occurs after value.
      boolean before​(java.util.Date date)
      Returns true if this range occurs before value.
      long durationInMillis()
      Returns this range's duration as a millisecond value.
      java.util.Date end()
      Returns the ending value of this range.
      java.sql.Timestamp endStamp()
      Returns the ending date of this range as a Timestamp instance.
      boolean includesDate​(java.util.Date date)
      Returns true if date occurs within this range.
      boolean intersectsRange​(java.util.Date start, java.util.Date end)
      Returns true if start and end intersect this range.
      boolean intersectsRange​(DateRange range)
      Returns true if range intersects this range.
      java.util.Date start()
      Returns the starting value of this range.
      java.sql.Timestamp startStamp()
      Returns the starting date of this range as a Timestamp instance.
      protected static java.util.Date timestampToDate​(java.util.Date date)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • MIN_DATE

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

        public static final java.util.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 Detail

      • DateRange

        public DateRange​(java.util.Date start,
                         java.util.Date end)
        Parameters:
        start - If null, defaults to MIN_DATE
        end - If null, defaults to MAX_DATE
    • Method Detail

      • timestampToDate

        protected static java.util.Date timestampToDate​(java.util.Date date)
      • after

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

        public boolean before​(java.util.Date date)
        Description copied from interface: Range
        Returns true if this range occurs before value.
        Specified by:
        before in interface Range<java.util.Date>
        Overrides:
        before in class ComparableRange<java.util.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 java.util.Date end()
        Description copied from interface: Range
        Returns the ending value of this range.
        Specified by:
        end in interface Range<java.util.Date>
        Overrides:
        end in class ComparableRange<java.util.Date>
        Returns:
        Ending value
      • endStamp

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

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

        public boolean intersectsRange​(java.util.Date start,
                                       java.util.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 java.util.Date start()
        Description copied from interface: Range
        Returns the starting value of this range.
        Specified by:
        start in interface Range<java.util.Date>
        Overrides:
        start in class ComparableRange<java.util.Date>
        Returns:
        Starting value
      • startStamp

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