19 package org.sleuthkit.autopsy.timeline.utils;
21 import javax.annotation.concurrent.Immutable;
22 import org.joda.time.DateTime;
23 import org.joda.time.DateTimeFieldType;
24 import org.joda.time.Days;
25 import org.joda.time.Hours;
26 import org.joda.time.Interval;
27 import org.joda.time.Minutes;
28 import org.joda.time.Months;
29 import org.joda.time.Seconds;
30 import org.joda.time.Years;
31 import org.joda.time.format.DateTimeFormat;
32 import org.joda.time.format.DateTimeFormatter;
33 import org.joda.time.format.ISODateTimeFormat;
70 private RangeDivisionInfo(Interval timeRange,
int periodsInRange,
TimeUnits periodSize, DateTimeFormatter tickformatter,
long lowerBound,
long upperBound) {
72 this.numberOfBlocks = periodsInRange;
73 this.blockSize = periodSize;
74 this.tickFormatter = tickformatter;
95 DateTimeFieldType timeUnit;
99 if (Years.yearsIn(timeRange).isGreaterThan(Years.THREE)) {
100 timeUnit = DateTimeFieldType.year();
101 long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
102 long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
103 return new RangeDivisionInfo(timeRange, Years.yearsIn(timeRange).get(timeUnit.getDurationType()) + 1,
TimeUnits.
YEARS, ISODateTimeFormat.year(), lower, upper);
104 }
else if (Months.monthsIn(timeRange).isGreaterThan(Months.THREE)) {
105 timeUnit = DateTimeFieldType.monthOfYear();
106 long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
107 long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
108 return new RangeDivisionInfo(timeRange, Months.monthsIn(timeRange).getMonths() + 1,
TimeUnits.
MONTHS, DateTimeFormat.forPattern(
"YYYY'-'MMMM"), lower, upper);
109 }
else if (Days.daysIn(timeRange).isGreaterThan(Days.THREE)) {
110 timeUnit = DateTimeFieldType.dayOfMonth();
111 long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
112 long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
113 return new RangeDivisionInfo(timeRange, Days.daysIn(timeRange).getDays() + 1,
TimeUnits.
DAYS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd"), lower, upper);
114 }
else if (Hours.hoursIn(timeRange).isGreaterThan(Hours.THREE)) {
115 timeUnit = DateTimeFieldType.hourOfDay();
116 long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
117 long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
118 return new RangeDivisionInfo(timeRange, Hours.hoursIn(timeRange).getHours() + 1,
TimeUnits.
HOURS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH"), lower, upper);
119 }
else if (Minutes.minutesIn(timeRange).isGreaterThan(Minutes.THREE)) {
120 timeUnit = DateTimeFieldType.minuteOfHour();
121 long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
122 long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
123 return new RangeDivisionInfo(timeRange, Minutes.minutesIn(timeRange).getMinutes() + 1,
TimeUnits.
MINUTES, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH':'mm"), lower, upper);
125 timeUnit = DateTimeFieldType.secondOfMinute();
126 long lower = startWithZone.property(timeUnit).roundFloorCopy().getMillis();
127 long upper = endWithZone.property(timeUnit).roundCeilingCopy().getMillis();
128 return new RangeDivisionInfo(timeRange, Seconds.secondsIn(timeRange).getSeconds() + 1,
TimeUnits.
SECONDS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH':'mm':'ss"), lower, upper);
DateTimeFormatter getTickFormatter()
final DateTimeFormatter tickFormatter
static RangeDivisionInfo getRangeDivisionInfo(Interval timeRange)
final TimeUnits blockSize
static DateTimeZone getJodaTimeZone()
TimeUnits getPeriodSize()
RangeDivisionInfo(Interval timeRange, int periodsInRange, TimeUnits periodSize, DateTimeFormatter tickformatter, long lowerBound, long upperBound)