Class JodaUtils

java.lang.Object
org.apache.druid.java.util.common.JodaUtils

public class JodaUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.
    static org.joda.time.DateTime
    maxDateTime(org.joda.time.DateTime... times)
     
    static org.joda.time.DateTime
    minDateTime(org.joda.time.DateTime... times)
     
    static org.joda.time.Interval
    umbrellaInterval(Iterable<org.joda.time.Interval> intervals)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • JodaUtils

      public JodaUtils()
  • Method Details

    • 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)