1 package ca.uhn.fhir.model.api;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import java.util.Calendar;
24 import java.util.Date;
25
26 import org.apache.commons.lang3.time.DateUtils;
27
28 public enum TemporalPrecisionEnum {
29
30 YEAR(Calendar.YEAR) {
31 @Override
32 public Date add(Date theInput, int theAmount) {
33 return DateUtils.addYears(theInput, theAmount);
34 }
35 },
36
37 MONTH(Calendar.MONTH) {
38 @Override
39 public Date add(Date theInput, int theAmount) {
40 return DateUtils.addMonths(theInput, theAmount);
41 }
42 },
43 DAY(Calendar.DATE) {
44 @Override
45 public Date add(Date theInput, int theAmount) {
46 return DateUtils.addDays(theInput, theAmount);
47 }
48 },
49 SECOND(Calendar.SECOND) {
50 @Override
51 public Date add(Date theInput, int theAmount) {
52 return DateUtils.addSeconds(theInput, theAmount);
53 }
54 },
55
56 MILLI(Calendar.MILLISECOND) {
57 @Override
58 public Date add(Date theInput, int theAmount) {
59 return DateUtils.addMilliseconds(theInput, theAmount);
60 }
61 },
62
63 ;
64
65 private int myCalendarConstant;
66
67 TemporalPrecisionEnum(int theCalendarConstant) {
68 myCalendarConstant = theCalendarConstant;
69 }
70
71 public abstract Date add(Date theInput, int theAmount);
72
73 public int getCalendarConstant() {
74 return myCalendarConstant;
75 }
76
77 }