Commit 0b058b94e9924912879d9be7d6c800ea48ba3b85
Exists in
master
Merge branch 'master' of http://ferramentasgo.centralit.com.br:8080/scm/git/cit-grp-corporativo
Showing
2 changed files
with
43 additions
and
6 deletions
Show diff stats
cit-core/src/main/java/br/com/centralit/framework/model/WorkDay.java
... | ... | @@ -150,7 +150,7 @@ public class WorkDay extends PersistentObjectAudit{ |
150 | 150 | * @return |
151 | 151 | */ |
152 | 152 | public long[] startTimeToArray() { |
153 | - if (this.getWorkTimes() == null) | |
153 | + if (this.getWorkTimes() == null || this.getWorkTimes().size() == 0) | |
154 | 154 | return new long[0]; |
155 | 155 | |
156 | 156 | long[] array = new long[this.getWorkTimes().size()]; |
... | ... | @@ -172,7 +172,7 @@ public class WorkDay extends PersistentObjectAudit{ |
172 | 172 | * @return |
173 | 173 | */ |
174 | 174 | public long[] endTimeToArray() { |
175 | - if (this.getWorkTimes() == null) | |
175 | + if (this.getWorkTimes() == null || this.getWorkTimes().size() == 0) | |
176 | 176 | return new long[0]; |
177 | 177 | |
178 | 178 | long[] array = new long[this.getWorkTimes().size()]; |
... | ... | @@ -245,7 +245,7 @@ public class WorkDay extends PersistentObjectAudit{ |
245 | 245 | * @return |
246 | 246 | */ |
247 | 247 | public long getEndWorkTime() { |
248 | - if (this.getWorkTimes() == null) | |
248 | + if (this.getWorkTimes() == null || this.getWorkTimes().size() == 0) | |
249 | 249 | return 0; |
250 | 250 | |
251 | 251 | final long[] endArray = this.endTimeToArray(); |
... | ... | @@ -260,7 +260,7 @@ public class WorkDay extends PersistentObjectAudit{ |
260 | 260 | * @return |
261 | 261 | */ |
262 | 262 | public long getStartWorkTime() { |
263 | - if (this.getWorkTimes() == null) | |
263 | + if (this.getWorkTimes() == null || this.getWorkTimes().size() == 0) | |
264 | 264 | return 0; |
265 | 265 | |
266 | 266 | final long[] startArray = this.startTimeToArray(); |
... | ... | @@ -275,7 +275,7 @@ public class WorkDay extends PersistentObjectAudit{ |
275 | 275 | * @return |
276 | 276 | */ |
277 | 277 | public long calculateIntervals(final long startTime, final long endTime) { |
278 | - if (this.getWorkTimes() == null) | |
278 | + if (this.getWorkTimes() == null || this.getWorkTimes().size() == 0) | |
279 | 279 | return 0; |
280 | 280 | |
281 | 281 | long interval = 0; |
... | ... | @@ -333,7 +333,7 @@ public class WorkDay extends PersistentObjectAudit{ |
333 | 333 | * @return |
334 | 334 | */ |
335 | 335 | public long getNextEndWorkTime(final long timeRef) { |
336 | - if (this.getWorkTimes() == null) | |
336 | + if (this.getWorkTimes() == null || this.getWorkTimes().size() == 0) | |
337 | 337 | return 0; |
338 | 338 | |
339 | 339 | final long[] endArray = this.endTimeToArray(); | ... | ... |
cit-core/src/main/java/br/com/centralit/framework/util/UtilDate.java
... | ... | @@ -96,6 +96,40 @@ public class UtilDate { |
96 | 96 | String[] data = value.split("/"); |
97 | 97 | return new Date(data[0] + "/" + 1 + "/" + data[1]); |
98 | 98 | } |
99 | + | |
100 | + public static Calendar stringToCalendar(String value){ | |
101 | + Calendar calendar = Calendar.getInstance(); | |
102 | + calendar.setTime(stringToDate(value)); | |
103 | + return calendar; | |
104 | + } | |
105 | + | |
106 | + public static Calendar zeraHoraMinSeg(Calendar calendar){ | |
107 | + calendar.set(Calendar.HOUR, 0); | |
108 | + calendar.set(Calendar.MINUTE, 0); | |
109 | + calendar.set(Calendar.SECOND, 0); | |
110 | + | |
111 | + return calendar; | |
112 | + } | |
113 | + | |
114 | + public static Calendar zeraHoraMinSeg(Date date){ | |
115 | + Calendar calendar = Calendar.getInstance(); | |
116 | + calendar.setTime(date); | |
117 | + return zeraHoraMinSeg(calendar); | |
118 | + } | |
119 | + | |
120 | + public static Calendar ultimaHoraMinSeg(Calendar calendar){ | |
121 | + calendar.set(Calendar.HOUR, 23); | |
122 | + calendar.set(Calendar.MINUTE,59); | |
123 | + calendar.set(Calendar.SECOND, 59); | |
124 | + | |
125 | + return calendar; | |
126 | + } | |
127 | + | |
128 | + public static Calendar ultimaHoraMinSeg(Date date){ | |
129 | + Calendar calendar = Calendar.getInstance(); | |
130 | + calendar.setTime(date); | |
131 | + return ultimaHoraMinSeg(calendar); | |
132 | + } | |
99 | 133 | |
100 | 134 | public static Timestamp timestampToTimestampDate(Timestamp data) { |
101 | 135 | Calendar cal = timestampToCalendar(data); |
... | ... | @@ -1168,6 +1202,9 @@ public class UtilDate { |
1168 | 1202 | } |
1169 | 1203 | |
1170 | 1204 | public static boolean isFeriadoNacional(Date data) { |
1205 | + if (data == null) | |
1206 | + return false; | |
1207 | + | |
1171 | 1208 | int dia = 0; |
1172 | 1209 | int mes = 0; |
1173 | 1210 | int c = 0; | ... | ... |