Revision 728

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/impl/DefaultDataTypesManager.java
57 57
        this.addtype(STRING, null, "String", String.class, new CoerceToString());
58 58
        this.addtype(DATE, SUBTYPE_DATE, "Date", Date.class, new CoerceToDate());
59 59
        this.addtype(TIME, SUBTYPE_DATE, "Time", Date.class, new CoerceToTime());
60
        this.addtype(TIMESTAMP, SUBTYPE_DATE, "Timestamp",
61
            Timestamp.class,
62
            new CoerceToTimestamp());
60
        this.addtype(TIMESTAMP, null, "Timestamp", Timestamp.class, new CoerceToTimestamp());
63 61

  
64 62
        this.addtype(BYTEARRAY, null, "ByteArray", null, null);
65 63
        this.addtype(FILE, SUBTYPE_FILE, "File", File.class, new CoerceToFile());
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/impl/coercion/CoerceToTimestamp.java
43 43
 * @author jldominguez
44 44
 *
45 45
 */
46
public class CoerceToTimestamp implements Coercion {
46
public class CoerceToTimestamp extends CoerceToTime {
47 47

  
48 48
    public static final String NOW_STRING = "now";
49 49
    
......
76 76
            // ----------- (3) Accept "now"
77 77
            if (NOW_STRING.compareToIgnoreCase(str.trim()) == 0) {
78 78
                
79
                return new Timestamp(System.currentTimeMillis());
80
                
81
            } else {
82
                /*
83
                 * Finally throw exception
84
                 */
85
                throw new CoercionException(
86
                    "Unable to coerce to Timestamp from: '" + str + "'");
79
                resp = new Timestamp(System.currentTimeMillis());
87 80
            }
81
            
82
            if (resp != null) {
83
                return resp;
84
            }
85

  
86
            /*
87
             * Finally try as time
88
             */
89
            return super.coerce(value);
88 90
        }
89 91
    }
90 92

  
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/usability/spinner/editor/DynFieldFormatter.java
9 9
import java.util.Calendar;
10 10
import java.util.Date;
11 11
import java.util.Locale;
12
import java.sql.Timestamp;
12 13

  
13 14
import org.gvsig.tools.dataTypes.DataTypes;
14 15
import org.gvsig.tools.dynobject.DynField;
......
337 338
		}
338 339

  
339 340
		if (isDate()) {
340
            return this.df.parse(value);
341
		    if (getType() == DataTypes.TIMESTAMP) {
342
		        /*
343
		         * Parse as timestamp
344
		         */
345
		        return Timestamp.valueOf(value);
346

  
347
		    } else {
348
		        return this.df.parse(value);
349
		    }
341 350
        }
342 351
        if (isNumber()) {
343 352
            return this.f.parse(value);
......
364 373
        case DataTypes.TIMESTAMP:
365 374
            this.isDate = true;
366 375
            this.calendarField = Calendar.SECOND;
367
            this.df =
368
                (SimpleDateFormat) DateFormat.getTimeInstance(
369
                    DateFormat.MEDIUM, getLocale());
376
            /*
377
             * This 'df' will not be used because Timestamp
378
             * is parsed in another way
379
             */
380
            this.df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.f");
381
            
370 382
            break;
371 383
        case DataTypes.DATE:
372 384
            this.isDate = true;

Also available in: Unified diff