com.ibm.tivoli.maximo.util

Class DateRange

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable
    Direct Known Subclasses:
    DateRangeWithValue


    public class DateRange
    extends Range
    implements java.io.Serializable, java.lang.Comparable
    Structure to hold a Date Range (start/end) and the value for that specific range. Note that comparisons done in this class are only accurate to the Second and not the Millisecond.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean after(java.util.Date d)
      Is our Start date after the given date
      boolean after(Range date)
      Is our START date after the end date of the given range
      static DateRange asDateRange(Range range) 
      Range asRange() 
      boolean before(java.util.Date date)
      is our range END before this date
      boolean before(Range date)
      Is our date range END before the date's START
      int compareTo(DateRange o) 
      void ensureRange(DateRange range)
      Given a Range, ensure that this range can contain the new range.
      boolean equals(java.lang.Object o) 
      void expandEnd(int days)
      Given the days, pad the end by that number of days
      void expandEnd(int days, DateRange other) 
      void expandRange(int days)
      Given the days, pad the start and end by that number of days
      void expandRange(int days, DateRange other)
      Given the days, pad the start and end by that number of days, taking into account the difference in days from the passed in range start end and this start end, to ensure that our padding is at least days.
      void expandStart(int days)
      Given the days, pad the start by that number of days
      void expandStart(int days, DateRange other) 
      long getDurationInMillis()
      Get the duration of the Date Range in milliseconds.
      boolean intersects(java.util.Date clickdate)
      Tests whether or not the given date intersects this range to the second.
      boolean intersects(Range date)
      Tests whether or not the given range intersects with this range, to the second.
      void normalize()
      Will normalize the dates so that start is actuall before the end.
      void normalize(DateRange dates)
      Will normalize, ensuring that the Start/End is not null.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

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

      • DateRange

        public DateRange(Range range)
      • DateRange

        public DateRange(java.util.Date start,
                         java.util.Date end)
      • DateRange

        public DateRange()
    • Method Detail

      • intersects

        public boolean intersects(java.util.Date clickdate)
        Tests whether or not the given date intersects this range to the second.
        Parameters:
        clickdate -
        Returns:
      • intersects

        public boolean intersects(Range date)
        Tests whether or not the given range intersects with this range, to the second. Ranges that align on a start/end end/start boundary are NOT considered to intersect. eg, A end at 10:00am an B starts at 10:00am then they do not intersect, even though they share a boundary.
        Parameters:
        date -
        Returns:
      • before

        public boolean before(java.util.Date date)
        is our range END before this date
        Parameters:
        date -
        Returns:
      • before

        public boolean before(Range date)
        Is our date range END before the date's START
        Parameters:
        date -
        Returns:
      • after

        public boolean after(java.util.Date d)
        Is our Start date after the given date
        Parameters:
        d -
        Returns:
      • after

        public boolean after(Range date)
        Is our START date after the end date of the given range
        Parameters:
        date -
        Returns:
      • normalize

        public void normalize()
        Will normalize the dates so that start is actuall before the end. If start is after the end, then the dates are swapped.
      • normalize

        public void normalize(DateRange dates)
        Will normalize, ensuring that the Start/End is not null.
        Parameters:
        dates -
      • ensureRange

        public void ensureRange(DateRange range)
        Given a Range, ensure that this range can contain the new range. If it cant' widen this range to enable it.
        Parameters:
        range -
      • expandRange

        public void expandRange(int days)
        Given the days, pad the start and end by that number of days
        Parameters:
        days -
      • expandStart

        public void expandStart(int days)
        Given the days, pad the start by that number of days
        Parameters:
        days -
      • expandEnd

        public void expandEnd(int days)
        Given the days, pad the end by that number of days
        Parameters:
        days -
      • expandRange

        public void expandRange(int days,
                                DateRange other)
        Given the days, pad the start and end by that number of days, taking into account the difference in days from the passed in range start end and this start end, to ensure that our padding is at least days. It could larger, if our start is more than the days from the passed in range. Same for the end.
        Parameters:
        days -
      • expandStart

        public void expandStart(int days,
                                DateRange other)
      • expandEnd

        public void expandEnd(int days,
                              DateRange other)
      • getDurationInMillis

        public long getDurationInMillis()
        Get the duration of the Date Range in milliseconds.
        Returns:
      • asRange

        public Range asRange()
      • compareTo

        public int compareTo(DateRange o)
        Specified by:
        compareTo in interface java.lang.Comparable
      • equals

        public boolean equals(java.lang.Object o)
        Overrides:
        equals in class Range
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Range