1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sourceforge.plantumldependency.common.utils.date;
26
27 import static net.sourceforge.plantumldependency.common.constants.log.ErrorConstants.IMMUTABLE_DATE_ERROR;
28 import static net.sourceforge.plantumldependency.common.utils.log.LogUtils.buildLogString;
29
30 import java.util.Date;
31
32
33
34
35
36
37
38
39 public class UnmodifiableDate extends Date {
40
41
42 private static final long serialVersionUID = -1580684205510917528L;
43
44
45
46
47
48
49 public UnmodifiableDate() {
50 super();
51 }
52
53
54
55
56
57
58
59
60 public UnmodifiableDate(final Date date) {
61 super(date.getTime());
62 }
63
64
65
66
67
68
69
70
71
72
73
74 public UnmodifiableDate(final long date) {
75 super(date);
76 }
77
78
79
80
81
82
83 @Override
84 public void setDate(final int date) {
85 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
86 }
87
88
89
90
91
92
93 @Override
94 public void setHours(final int hours) {
95 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
96 }
97
98
99
100
101
102
103 @Override
104 public void setMinutes(final int minutes) {
105 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
106 }
107
108
109
110
111
112
113 @Override
114 public void setMonth(final int month) {
115 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
116 }
117
118
119
120
121
122
123 @Override
124 public void setSeconds(final int seconds) {
125 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
126 }
127
128
129
130
131
132
133 @Override
134 public void setTime(final long time) {
135 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
136 }
137
138
139
140
141
142
143 @Override
144 public void setYear(final int year) {
145 throw new IllegalArgumentException(buildLogString(IMMUTABLE_DATE_ERROR, this));
146 }
147 }