Revision 2160 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/impl/coercion/AbstractCoerceToDate.java

View differences:

AbstractCoerceToDate.java
32 32

  
33 33
import org.gvsig.tools.dataTypes.CoercionException;
34 34
import org.gvsig.tools.dataTypes.DataTypeUtils;
35
import org.gvsig.tools.dataTypes.DataTypesManager;
36 35
import org.gvsig.tools.dataTypes.CoercionContext;
37 36
import org.gvsig.tools.dataTypes.CoercionContextLocale;
38 37

  
......
53 52

  
54 53
  @Override
55 54
  public Object coerce(Object value, CoercionContext context) throws CoercionException {
55
    if( value == null ) {
56
      return null;
57
    }
58
    if (value instanceof Date) {
59
      return this.valueOf(((Date) value));
60
    }
56 61
    Locale locale;
57 62
    if (context instanceof CoercionContextLocale) {
58 63
      locale = ((CoercionContextLocale) context).locale();
......
90 95
      try {
91 96
        Date d = formatter.parse(valueStr);
92 97
        if (d != null) {
93
          return d;
98
          return this.valueOf(d);
94 99
        }
95 100
      } catch (ParseException e) {
96 101
        // Continue
......
128 133
  protected abstract DateFormat[] getFormatters(Locale locale);
129 134

  
130 135
  protected Date now() {
131
    Date d = new Date();
136
    Date d = this.valueOf(new Date());
132 137
    return d;
133 138
  }
134 139

  
......
136 141
    return null;
137 142
  }
138 143

  
144
  protected Date valueOf(Date value) {
145
    return value;
146
  }
147

  
139 148
  /**
140 149
   * Returns the name of the Date type being coerced. Ex: Date, DateTime, Time.
141 150
   * Only used for description when an error is produced when coercing the

Also available in: Unified diff