1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package de.bea.domingo.util;
23
24 import java.util.Calendar;
25
26 import de.bea.domingo.DDateRange;
27
28
29 /***
30 * A date/time range.
31 *
32 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
33 */
34 public final class GregorianDateTimeRange implements DDateRange {
35
36 private GregorianDateTime fStart;
37
38 private GregorianDateTime fEnd;
39
40 /***
41 * Constructor.
42 */
43 public GregorianDateTimeRange() {
44 }
45
46 /***
47 * Constructor.
48 *
49 * @param start start date
50 * @param end end date
51 */
52 public GregorianDateTimeRange(final Calendar start, final Calendar end) {
53 setFrom(start);
54 setTo(end);
55 }
56
57 /***
58 * Returns the end date of the date range.
59 *
60 * @return start date
61 */
62 public Calendar getFrom() {
63 return fStart;
64 }
65
66 /***
67 * Returns the end date of the date range.
68 *
69 * @return end date
70 */
71 public Calendar getTo() {
72 return fEnd;
73 }
74
75 /***
76 * Sets the end date of the date range.
77 *
78 * @param end end date
79 */
80 public void setTo(final Calendar end) {
81 if (end instanceof GregorianDateTime) {
82 fEnd = (GregorianDateTime) end;
83 } else {
84 fEnd = new GregorianDateTime(end);
85 }
86 }
87
88 /***
89 * Sets the end date of the date range.
90 *
91 * @param start start date
92 */
93 public void setFrom(final Calendar start) {
94 if (start instanceof GregorianDateTime) {
95 fStart = (GregorianDateTime) start;
96 } else {
97 fStart = new GregorianDateTime(start);
98 }
99 }
100
101 /***
102 * {@inheritDoc}
103 * @see java.util.Calendar#toString()
104 */
105 public String toString() {
106 return DateUtil.getDateTimeString(getFrom()) + " - " + DateUtil.getDateTimeString(getTo());
107 }
108 }