Class Intervals


  • public final class Intervals
    extends Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.joda.time.Interval ETERNITY  
      static com.google.common.collect.ImmutableList<org.joda.time.Interval> ONLY_ETERNITY  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canCompareEndpointsAsStrings​(org.joda.time.Interval interval)
      Returns true if the provided interval has endpoints that can be compared against other DateTimes using their string representations.
      static org.joda.time.Interval findOverlappingInterval​(org.joda.time.Interval searchInterval, org.joda.time.Interval[] sortedIntervals)
      Finds an interval from the given set of sortedIntervals which overlaps with the searchInterval.
      static boolean isEmpty​(org.joda.time.Interval interval)  
      static boolean isEternity​(org.joda.time.Interval interval)
      Returns true if the provided interval contains all time.
      static org.joda.time.Interval of​(String interval)  
      static org.joda.time.Interval of​(String format, Object... formatArgs)  
      static org.joda.time.Interval utc​(long startInstant, long endInstant)  
    • Field Detail

      • ETERNITY

        public static final org.joda.time.Interval ETERNITY
      • ONLY_ETERNITY

        public static final com.google.common.collect.ImmutableList<org.joda.time.Interval> ONLY_ETERNITY
    • Method Detail

      • utc

        public static org.joda.time.Interval utc​(long startInstant,
                                                 long endInstant)
      • of

        public static org.joda.time.Interval of​(String interval)
      • of

        public static org.joda.time.Interval of​(String format,
                                                Object... formatArgs)
      • isEmpty

        public static boolean isEmpty​(org.joda.time.Interval interval)
      • canCompareEndpointsAsStrings

        public static boolean canCompareEndpointsAsStrings​(org.joda.time.Interval interval)
        Returns true if the provided interval has endpoints that can be compared against other DateTimes using their string representations. See also DateTimes.canCompareAsString(DateTime).
      • isEternity

        public static boolean isEternity​(org.joda.time.Interval interval)
        Returns true if the provided interval contains all time.
      • findOverlappingInterval

        @Nullable
        public static org.joda.time.Interval findOverlappingInterval​(org.joda.time.Interval searchInterval,
                                                                     org.joda.time.Interval[] sortedIntervals)
        Finds an interval from the given set of sortedIntervals which overlaps with the searchInterval. If multiple candidate intervals overlap with the searchInterval, the "smallest" interval based on the Comparators.intervalsByStartThenEnd() is returned.
        Parameters:
        searchInterval - Interval which should overlap with the result
        sortedIntervals - Candidate overlapping intervals, sorted in ascending order, using Comparators.intervalsByStartThenEnd().
        Returns:
        The first overlapping interval, if one exists, otherwise null.