Autopsy  3.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 
31 public enum TimeUnits {
32 
33  FOREVER(null, ChronoUnit.FOREVER),
34  YEARS(Years.ONE.toPeriod(), ChronoUnit.YEARS),
35  MONTHS(Months.ONE.toPeriod(), ChronoUnit.MONTHS),
36  DAYS(Days.ONE.toPeriod(), ChronoUnit.DAYS),
37  HOURS(Hours.ONE.toPeriod(), ChronoUnit.HOURS),
38  MINUTES(Minutes.ONE.toPeriod(), ChronoUnit.MINUTES),
39  SECONDS(Seconds.ONE.toPeriod(), ChronoUnit.SECONDS);
40 
41  public static TimeUnits fromChronoUnit(ChronoUnit chronoUnit) {
42  switch (chronoUnit) {
43 
44  case FOREVER:
45  return FOREVER;
46  case ERAS:
47  case MILLENNIA:
48  case CENTURIES:
49  case DECADES:
50  case YEARS:
51  return YEARS;
52  case MONTHS:
53  return MONTHS;
54  case WEEKS:
55  case DAYS:
56  return DAYS;
57  case HOURS:
58  case HALF_DAYS:
59  return HOURS;
60  case MINUTES:
61  return MINUTES;
62  case SECONDS:
63  case MILLIS:
64  case MICROS:
65  case NANOS:
66  return SECONDS;
67  default:
68  return YEARS;
69  }
70  }
71 
72  private final Period p;
73 
74  private final ChronoUnit cu;
75 
76  public Period getPeriod() {
77  return p;
78  }
79 
80  public ChronoUnit getChronoUnit() {
81  return cu;
82  }
83 
84  private TimeUnits(Period p, ChronoUnit cu) {
85  this.p = p;
86  this.cu = cu;
87  }
88 }
static TimeUnits fromChronoUnit(ChronoUnit chronoUnit)
Definition: TimeUnits.java:41

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