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