| 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 |
|
|
|
|
|
| 26,7% |
Uncovered Elements: 11 (15) |
Complexity: 6 |
Complexity Density: 0,75 |
|
| 35 |
|
public class TimeConverter extends Converter { |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
protected int format; |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@param |
| 46 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 47 |
1
|
public TimeConverter() {... |
| 48 |
1
|
this(DateFormat.SHORT); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@param |
| 55 |
|
@param |
| 56 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
1
|
public TimeConverter(int format) {... |
| 58 |
1
|
this.format = format; |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
|
| 62 |
|
@see |
| 63 |
|
|
| 64 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0,67 |
|
| 65 |
0
|
public Object convert(Class type, Object value, Locale locale) throws ConversionException {... |
| 66 |
0
|
try { |
| 67 |
0
|
if (type.equals(java.sql.Time.class)) { |
| 68 |
0
|
return new java.sql.Time(DateFormat.getTimeInstance(format, locale).parse(value.toString()).getTime()); |
| 69 |
0
|
} else if (type.equals(java.util.Date.class)) { |
| 70 |
0
|
return DateFormat.getTimeInstance(format, locale).parse(value.toString()); |
| 71 |
|
} else { |
| 72 |
0
|
return DateFormat.getTimeInstance(format, locale).format(((java.util.Date)value)); |
| 73 |
|
} |
| 74 |
|
} catch (ParseException pe) { |
| 75 |
|
throw new ConversionException("Invalid date " + value.toString(), pe); |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
} |