Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
TimeUnits.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.zooming;
20 
21 import java.time.temporal.ChronoUnit;
22 import org.joda.time.Days;
23 import org.joda.time.Hours;
24 import org.joda.time.Minutes;
25 import org.joda.time.Months;
26 import org.joda.time.Period;
27 import org.joda.time.Seconds;
28 import org.joda.time.Years;
29 
33 public enum TimeUnits implements DisplayNameProvider {
34 
35  FOREVER(null, ChronoUnit.FOREVER),
36  YEARS(Years.ONE.toPeriod(), ChronoUnit.YEARS),
37  MONTHS(Months.ONE.toPeriod(), ChronoUnit.MONTHS),
38  DAYS(Days.ONE.toPeriod(), ChronoUnit.DAYS),
39  HOURS(Hours.ONE.toPeriod(), ChronoUnit.HOURS),
40  MINUTES(Minutes.ONE.toPeriod(), ChronoUnit.MINUTES),
41  SECONDS(Seconds.ONE.toPeriod(), ChronoUnit.SECONDS);
42 
43  public static TimeUnits fromChronoUnit(ChronoUnit chronoUnit) {
44  switch (chronoUnit) {
45 
46  case FOREVER:
47  return FOREVER;
48  case ERAS:
49  case MILLENNIA:
50  case CENTURIES:
51  case DECADES:
52  case YEARS:
53  return YEARS;
54  case MONTHS:
55  return MONTHS;
56  case WEEKS:
57  case DAYS:
58  return DAYS;
59  case HOURS:
60  case HALF_DAYS:
61  return HOURS;
62  case MINUTES:
63  return MINUTES;
64  case SECONDS:
65  case MILLIS:
66  case MICROS:
67  case NANOS:
68  return SECONDS;
69  default:
70  return YEARS;
71  }
72  }
73 
74  private final Period p;
75 
76  private final ChronoUnit cu;
77 
78  public Period getPeriod() {
79  return p;
80  }
81 
82  public ChronoUnit getChronoUnit() {
83  return cu;
84  }
85 
86  private TimeUnits(Period p, ChronoUnit cu) {
87  this.p = p;
88  this.cu = cu;
89  }
90 
91  @Override
92  public String getDisplayName() {
93  return toString();
94  }
95 }
static TimeUnits fromChronoUnit(ChronoUnit chronoUnit)
Definition: TimeUnits.java:43

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.