1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.validator; |
17 |
|
|
18 |
|
import java.text.SimpleDateFormat; |
19 |
|
import java.util.Date; |
20 |
|
|
|
|
| 63.2% |
Uncovered Elements: 7 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
21 |
|
public class ServerDateParser implements DateParser { |
22 |
|
SimpleDateFormat[] formats = { |
23 |
|
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"), |
24 |
|
new SimpleDateFormat("yyyy-MM-dd"), |
25 |
|
new SimpleDateFormat("yyyy-MMM-dd"), |
26 |
|
new SimpleDateFormat("dd-MM-yyyy"), |
27 |
|
new SimpleDateFormat("dd-MMM-yyyy") |
28 |
|
}; |
29 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
30 |
8
|
public Date parseDate(String input) {... |
31 |
8
|
Date result = null; |
32 |
|
|
33 |
8
|
for (SimpleDateFormat format : formats) { |
34 |
16
|
try { |
35 |
16
|
result = format.parse(input); |
36 |
|
} catch (Exception e) { |
37 |
|
|
38 |
|
} |
39 |
16
|
if (result != null) { |
40 |
8
|
break; |
41 |
|
} |
42 |
|
|
43 |
|
} |
44 |
|
|
45 |
8
|
if (result == null) { |
46 |
0
|
throw new DateParseException("Invalid date value: " + input); |
47 |
|
} |
48 |
|
|
49 |
8
|
return result; |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
@see |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
55 |
0
|
@Override... |
56 |
|
public String toString(Date date) { |
57 |
0
|
String result = null; |
58 |
0
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss,SSS"); |
59 |
0
|
result = format.format(date); |
60 |
|
|
61 |
0
|
return result; |
62 |
|
} |
63 |
|
} |