Revision 2160 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/impl/coercion/CoerceToDate.java
CoerceToDate.java | ||
---|---|---|
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
@Override |
61 |
protected Date now() { |
|
62 |
Date d = new Date(); |
|
63 |
d.setHours(0); |
|
64 |
d.setMinutes(0); |
|
65 |
d.setSeconds(0); |
|
66 |
return d; |
|
61 |
protected Date valueOf(Date value) { |
|
62 |
java.sql.Date dd = new java.sql.Date(value.getTime()); |
|
63 |
return dd; |
|
67 | 64 |
} |
68 | 65 |
|
69 | 66 |
@Override |
... | ... | |
71 | 68 |
return "Date"; |
72 | 69 |
} |
73 | 70 |
|
74 |
@Override |
|
75 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
76 |
if( value == null ) { |
|
77 |
return null; |
|
78 |
} |
|
79 |
if (value instanceof Date) { |
|
80 |
Date d = (Date) value; |
|
81 |
Date n = new Date(d.getYear(), d.getMonth(), d.getDate(), 0, 0, 0); |
|
82 |
return n; |
|
83 |
} |
|
84 |
return super.coerce(value, context); |
|
85 |
} |
|
86 |
|
|
87 | 71 |
} |
Also available in: Unified diff