19 package org.sleuthkit.autopsy.timeline.zooming;
21 import java.time.temporal.ChronoUnit;
22 import org.apache.commons.lang3.StringUtils;
23 import org.joda.time.DateTime;
24 import org.joda.time.DateTimeFieldType;
25 import org.joda.time.Days;
26 import org.joda.time.Hours;
27 import org.joda.time.Minutes;
28 import org.joda.time.Months;
29 import org.joda.time.Period;
30 import org.joda.time.ReadablePeriod;
31 import org.joda.time.Seconds;
32 import org.joda.time.Years;
33 import org.joda.time.format.DateTimeFormat;
34 import org.joda.time.format.DateTimeFormatter;
35 import org.joda.time.format.ISODateTimeFormat;
42 FOREVER(null, null, ChronoUnit.FOREVER, null),
43 YEARS(DateTimeFieldType.year(), Years.ONE, ChronoUnit.YEARS, ISODateTimeFormat.year()),
44 MONTHS(DateTimeFieldType.monthOfYear(), Months.ONE, ChronoUnit.MONTHS, DateTimeFormat.forPattern(
"YYYY'-'MMMM")),
45 DAYS(DateTimeFieldType.dayOfMonth(), Days.ONE, ChronoUnit.DAYS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd")),
46 HOURS(DateTimeFieldType.hourOfDay(), Hours.ONE, ChronoUnit.HOURS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH")),
47 MINUTES(DateTimeFieldType.minuteOfHour(), Minutes.ONE, ChronoUnit.MINUTES, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH':'mm")),
48 SECONDS(DateTimeFieldType.secondOfMinute(), Seconds.ONE, ChronoUnit.SECONDS, DateTimeFormat.forPattern(
"YYYY'-'MMMM'-'dd HH':'mm':'ss"));
59 private TimeUnits(DateTimeFieldType fieldType, ReadablePeriod period, ChronoUnit chronoUnit, DateTimeFormatter tickFormatter) {
60 this.fieldType = fieldType;
62 this.period = period.toPeriod();
66 this.chronoUnit = chronoUnit;
67 this.tickFormatter = tickFormatter;
71 return dateTime.property(fieldType);
83 return StringUtils.capitalize(toString().toLowerCase());
final DateTimeFormatter tickFormatter
final DateTimeFieldType fieldType
DateTimeFormatter getTickFormatter()
ChronoUnit toChronoUnit()
final ChronoUnit chronoUnit
TimeUnits(DateTimeFieldType fieldType, ReadablePeriod period, ChronoUnit chronoUnit, DateTimeFormatter tickFormatter)
DateTime.Property propertyOf(DateTime dateTime)