Class JodaUtils


  • public class JodaUtils
    extends Object
    • Constructor Detail

      • JodaUtils

        public JodaUtils()
    • Method Detail

      • condenseIntervals

        public static List<org.joda.time.Interval> condenseIntervals​(Iterable<org.joda.time.Interval> intervals)
        Condense the provided intervals such that the returned list has no abutting intervals, no overlapping intervals, and no zero-length intervals.

        This method is most efficient if the input intervals are in a SortedSet whose comparator is Comparators.intervalsByStartThenEnd().

        Parameters:
        intervals - The Iterable object containing the intervals to condense
        Returns:
        The condensed intervals
      • condensedIntervalsIterator

        public static Iterator<org.joda.time.Interval> condensedIntervalsIterator​(Iterator<org.joda.time.Interval> sortedIntervals)
        Condense the provided intervals such that the returned list has no abutting intervals, no overlapping intervals, and no zero-length intervals.

        The provided intervals must be sorted in ascending order using Comparators.intervalsByStartThenEnd(). Otherwise, results are undefined.

        The method avoids materialization by incrementally condensing the intervals by starting from the first and looking for "adjacent" intervals. This is possible since intervals in the Iterator are in ascending order (as guaranteed by the caller).

        Parameters:
        sortedIntervals - The iterator object containing the intervals to condense
        Returns:
        An iterator for the condensed intervals. By construction the condensed intervals are sorted in ascending order and contain no repeated elements. The iterator can contain nulls, they will be skipped if it does.
        Throws:
        IAE - if an element is null or if sortedIntervals is not sorted in ascending order
      • umbrellaInterval

        public static org.joda.time.Interval umbrellaInterval​(Iterable<org.joda.time.Interval> intervals)
      • minDateTime

        public static org.joda.time.DateTime minDateTime​(org.joda.time.DateTime... times)
      • maxDateTime

        public static org.joda.time.DateTime maxDateTime​(org.joda.time.DateTime... times)