1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.lang3.time;
19
20 import java.time.ZoneId;
21 import java.util.Date;
22 import java.util.Locale;
23 import java.util.Objects;
24 import java.util.TimeZone;
25
26
27
28
29 final class ImmutableTimeZone extends TimeZone {
30
31 private static final long serialVersionUID = 1L;
32 private final TimeZone timeZone;
33
34 ImmutableTimeZone(final TimeZone timeZone) {
35 this.timeZone = Objects.requireNonNull(timeZone, "timeZone");
36 }
37
38 @Override
39 public Object clone() {
40
41 return this;
42 }
43
44
45
46
47 @Override
48 public boolean equals(final Object obj) {
49 if (this == obj) {
50 return true;
51 }
52 if (!(obj instanceof TimeZone)) {
53 return false;
54 }
55 final TimeZone other = (TimeZone) obj;
56 return timeZone.equals(other instanceof ImmutableTimeZone ? ((ImmutableTimeZone) other).timeZone : other);
57 }
58
59
60
61
62 @Override
63 public String getDisplayName(final boolean daylight, final int style, final Locale locale) {
64 return timeZone.getDisplayName(daylight, style, locale);
65 }
66
67
68
69
70 @Override
71 public int getDSTSavings() {
72 return timeZone.getDSTSavings();
73 }
74
75
76
77
78 @Override
79 public String getID() {
80 return timeZone.getID();
81 }
82
83
84
85
86 @Override
87 public int getOffset(final int era, final int year, final int month, final int day, final int dayOfWeek, final int milliseconds) {
88 return timeZone.getOffset(era, year, month, day, dayOfWeek, milliseconds);
89 }
90
91
92
93
94 @Override
95 public int getOffset(final long date) {
96 return timeZone.getOffset(date);
97 }
98
99
100
101
102 @Override
103 public int getRawOffset() {
104 return timeZone.getRawOffset();
105 }
106
107
108
109
110 @Override
111 public int hashCode() {
112 return timeZone.hashCode();
113 }
114
115
116
117
118 @Override
119 public boolean hasSameRules(final TimeZone other) {
120 return timeZone.hasSameRules(other);
121 }
122
123
124
125
126 @Override
127 public boolean inDaylightTime(final Date date) {
128 return timeZone.inDaylightTime(date);
129 }
130
131
132
133
134 @Override
135 public boolean observesDaylightTime() {
136 return timeZone.observesDaylightTime();
137 }
138
139
140
141
142 @Override
143 public void setID(final String ID) {
144 throw new UnsupportedOperationException("This class is immutable.");
145 }
146
147
148
149
150 @Override
151 public void setRawOffset(final int offsetMillis) {
152 throw new UnsupportedOperationException("This class is immutable.");
153 }
154
155
156
157
158 @Override
159 public String toString() {
160 return timeZone.toString();
161 }
162
163
164
165
166 @Override
167 public ZoneId toZoneId() {
168 return timeZone.toZoneId();
169 }
170
171 TimeZone unwrap() {
172 return timeZone;
173 }
174
175 @Override
176 public boolean useDaylightTime() {
177 return timeZone.useDaylightTime();
178 }
179 }