1
2
3
4
5 package net.sourceforge.jsdp.util;
6
7 import java.io.Serializable;
8 import java.util.Date;
9
10 import net.sourceforge.jsdp.SDPException;
11 import net.sourceforge.jsdp.Time;
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class ZoneAdjustment implements Cloneable, Serializable {
26
27
28 private static final long serialVersionUID = -5613785303341511624L;
29
30
31 protected long offset;
32
33
34 protected long time;
35
36
37
38
39 protected ZoneAdjustment() {
40
41 super();
42 }
43
44
45
46
47
48
49
50
51
52
53
54 public ZoneAdjustment(final Date time, final long offset) throws SDPException {
55
56 super();
57
58 setTime(Time.getNTP(time));
59 this.offset = offset;
60 }
61
62
63
64
65
66
67
68
69
70
71 public ZoneAdjustment(final long time, final long offset) throws SDPException {
72
73 super();
74
75 setTime(time);
76 this.offset = offset;
77 }
78
79
80
81
82
83
84 public Object clone() {
85
86 ZoneAdjustment adjustment = new ZoneAdjustment();
87
88 adjustment.time = this.time;
89 adjustment.offset = this.offset;
90
91 return adjustment;
92 }
93
94
95
96
97
98
99 public long getOffset() {
100
101 return offset;
102 }
103
104
105
106
107
108
109 public long getTime() {
110
111 return time;
112 }
113
114
115
116
117
118
119 public void setOffset(final long offset) {
120
121 this.offset = offset;
122 }
123
124
125
126
127
128
129
130
131 public void setTime(final long time) throws SDPException {
132
133 if (time < 0) {
134 throw new SDPException("Adjustment time must be > 0");
135 }
136
137 this.time = time;
138 }
139
140
141
142
143
144
145
146 public String toString() {
147
148 return time + " " + offset;
149 }
150 }