19 package org.sleuthkit.autopsy.timeline.utils;
21 import java.time.Instant;
22 import java.time.temporal.TemporalAmount;
23 import java.util.Collection;
24 import org.joda.time.DateTime;
25 import org.joda.time.DateTimeZone;
26 import org.joda.time.Interval;
27 import org.joda.time.ReadablePeriod;
36 Interval trange = null;
37 for (DateTime t : times) {
39 trange =
new Interval(t.getMillis(), t.getMillis() + 1000, DateTimeZone.UTC);
47 static public Interval
span(Interval range,
final Interval range2) {
48 return new Interval(Math.min(range.getStartMillis(), range2.getStartMillis()), Math.max(range.getEndMillis(), range2.getEndMillis()), DateTimeZone.UTC);
51 static public Interval
extendInterval(Interval range,
final Long eventTime) {
52 return new Interval(Math.min(range.getStartMillis(), eventTime), Math.max(range.getEndMillis(), eventTime + 1), DateTimeZone.UTC);
55 public static DateTime
middleOf(Interval interval) {
56 return new DateTime((interval.getStartMillis() + interval.getEndMillis()) / 2);
64 DateTime start = aroundInstant.minus(period);
65 DateTime end = aroundInstant.plus(period);
66 Interval range =
new Interval(start, end);
68 long halfRange = range.toDurationMillis() / 4;
69 final Interval newInterval =
new Interval(middleOf.minus(halfRange), middleOf.plus(halfRange));
73 static public Interval
getIntervalAround(Instant aroundInstant, TemporalAmount temporalAmount) {
74 long start = aroundInstant.minus(temporalAmount).toEpochMilli();
75 long end = aroundInstant.plusMillis(1).plus(temporalAmount).toEpochMilli();
76 final Interval newInterval =
new Interval(start, Math.max(start + 1, end));
static Interval getIntervalAround(Instant aroundInstant, TemporalAmount temporalAmount)
static Interval span(Interval range, final Interval range2)
static Interval getAdjustedInterval(Interval oldInterval, TimeUnits requestedUnit)
static Interval getIntervalAroundMiddle(Interval interval, ReadablePeriod period)
static Interval getIntervalAround(DateTime aroundInstant, ReadablePeriod period)
static Interval getSpanningInterval(Collection< DateTime > times)
static Interval extendInterval(Interval range, final Long eventTime)
static DateTime middleOf(Interval interval)