Class TimeInterval


  • public class TimeInterval
    extends java.lang.Object
    A class representing a time interval, with utility methods to derive related intervals, check time stamps for containment, etc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      long fromMs  
      long toMs  
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeInterval​(long fromMs, long toMs)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(long timestampMs)
      Checks whether the interval contains the given time stamp.
      boolean endsAfter​(long timestampMs)
      Checks whether the interval end after the given time stamp.
      boolean equals​(java.lang.Object o)  
      long getDurationMs()
      Returns the duration in ms.
      int hashCode()  
      TimeInterval notEarlierThan​(long timestampMs)
      Shortens the interval to the specified start value, if is contained in the interval.
      TimeInterval notLaterThan​(long timestampMs)
      Shortens the interval to the specified end value, if is contained in the interval.
      TimeInterval startAndDuration​(long durationMs)
      Returns a new interval starting at the previous time, but ending after the specified duration.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • fromMs

        public final long fromMs
      • toMs

        public final long toMs
    • Constructor Detail

      • TimeInterval

        public TimeInterval​(long fromMs,
                            long toMs)
    • Method Detail

      • notLaterThan

        public TimeInterval notLaterThan​(long timestampMs)
        Shortens the interval to the specified end value, if is contained in the interval. Returns a single point in time interval when the specified time is outside the time interval. Return unchanged internal if specified value beyond end.
      • notEarlierThan

        public TimeInterval notEarlierThan​(long timestampMs)
        Shortens the interval to the specified start value, if is contained in the interval. Returns a single point in time interval when the specified time is outside the time interval. Return unchanged internal if specified value before start.
      • startAndDuration

        public TimeInterval startAndDuration​(long durationMs)
        Returns a new interval starting at the previous time, but ending after the specified duration.
      • getDurationMs

        public long getDurationMs()
        Returns the duration in ms.
      • contains

        public boolean contains​(long timestampMs)
        Checks whether the interval contains the given time stamp.
      • endsAfter

        public boolean endsAfter​(long timestampMs)
        Checks whether the interval end after the given time stamp.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

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