1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
package net.smartlab.web.bean; |
25 |
|
|
26 |
|
import java.text.DateFormat; |
27 |
|
import java.text.ParseException; |
28 |
|
import java.util.Locale; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@author |
34 |
|
|
|
|
| 41,7% |
Uncovered Elements: 7 (12) |
Complexity: 5 |
Complexity Density: 0,71 |
|
35 |
|
public class DateTimeConverter extends Converter { |
36 |
|
|
37 |
|
private int date; |
38 |
|
|
39 |
|
private int time; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@param |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
1
|
public DateTimeConverter() {... |
47 |
1
|
this(DateFormat.SHORT, DateFormat.SHORT); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
@param |
55 |
|
@param |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
57 |
1
|
public DateTimeConverter(int date, int time) {... |
58 |
1
|
this.date = date; |
59 |
1
|
this.time = time; |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
@see |
64 |
|
|
65 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0,75 |
|
66 |
0
|
public Object convert(Class type, Object value, Locale locale) throws ConversionException {... |
67 |
0
|
try { |
68 |
0
|
if (type.equals(java.sql.Timestamp.class)) { |
69 |
0
|
return new java.sql.Timestamp(DateFormat.getDateTimeInstance(date, time, locale).parse(value.toString()).getTime()); |
70 |
|
} else { |
71 |
0
|
return DateFormat.getDateTimeInstance(date, time, locale).format(((java.util.Date)value)); |
72 |
|
} |
73 |
|
} catch (ParseException pe) { |
74 |
|
throw new ConversionException("Invalid date " + value.toString(), pe); |
75 |
|
} |
76 |
|
} |
77 |
|
} |