Class Intervals
java.lang.Object
org.apache.druid.java.util.common.Intervals
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.joda.time.Intervalstatic final com.google.common.collect.ImmutableList<org.joda.time.Interval> -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanCompareEndpointsAsStrings(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 List<org.joda.time.Interval>complementOf(org.joda.time.Interval interval) static org.joda.time.IntervalfindOverlappingInterval(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 org.joda.time.IntervalfromString(String serializedInterval) A performance-optimized method for parsing a Joda-TimeIntervalfrom a string.static booleanisEternity(org.joda.time.Interval interval) Returns true if the provided interval contains all time.static org.joda.time.Intervalstatic org.joda.time.Intervalstatic org.joda.time.Intervalutc(long startInstant, long endInstant)
-
Field Details
-
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 Details
-
utc
public static org.joda.time.Interval utc(long startInstant, long endInstant) -
of
-
of
-
fromString
A performance-optimized method for parsing a Joda-TimeIntervalfrom a string. This method is significantly faster than the standardof(String)for the following group of offsets:- "2022-01-01T00:00:00.000Z/2022-01-02T00:00:00.000Z"
- "2022-01-01T00:00:00.000+05:30/2022-01-01T01:00:00.000+05:30"
- "2022-01-01T00:00:00.000+0530/2022-01-01T01:00:00.000+0530"
If the input string does not match the format, it will fall back to the more flexible but slower
of(String)parser. If you are dealing with any Intervals format examples below, consider usingof(String)instead:- "2022-01-01T00:00:00Z/2022-01-02T00:00:00Z" (without millis)
- "2022-01-01/2022-01-02" (Date only)
- "2022-01-01T12:00:00.000Z/PT6H" (Periods in start / end)
SegmentId. -
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 alsoDateTimes.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 theComparators.intervalsByStartThenEnd()is returned.- Parameters:
searchInterval- Interval which should overlap with the resultsortedIntervals- Candidate overlapping intervals, sorted in ascending order, usingComparators.intervalsByStartThenEnd().- Returns:
- The first overlapping interval, if one exists, otherwise null.
-
complementOf
- Returns:
- List of intervals which when added to the given interval create
ETERNITY.
-