Revision 1159 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
27 27
import java.text.ParseException;
28 28
import java.text.SimpleDateFormat;
29 29
import java.util.Date;
30
import java.util.Locale;
30 31

  
31 32
import org.gvsig.tools.dataTypes.CoercionException;
32
import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
33
import org.gvsig.tools.dataTypes.DataTypesManager.CoercionWithLocale;
33 34

  
34 35
/**
35 36
 * Abstract implementation for Date coercion classes. If the value is not a
......
39 40
 * @author gvSIG Team
40 41
 * @version $Id$
41 42
 */
42
public abstract class AbstractCoerceToDate implements Coercion {
43
public abstract class AbstractCoerceToDate implements CoercionWithLocale {
43 44

  
44 45
    public Object coerce(Object value) throws CoercionException {
46
        return coerce(value, Locale.getDefault());
47
    }
48

  
49
    public Object coerce(Object value, Locale locale) throws CoercionException {
45 50
    	if( value == null ) {
46 51
    		return null;
47 52
    	}
48 53
        if (!(value instanceof Date)) {
49
            DateFormat dateFormatter = createFormatter();
54
            DateFormat dateFormatter = createFormatter(locale);
50 55
            String valueStr = value.toString();
51 56
            if( valueStr == null ) {
52 57
                return null;
......
86 91
     * @return the {@link DateFormat} to apply to parse the value to coerce as
87 92
     *         {@link String}
88 93
     */
89
    protected abstract DateFormat createFormatter();
94
    protected abstract DateFormat createFormatter(Locale locale);
90 95

  
91 96
    /**
92 97
     * Returns the name of the Date type being coerced. Ex: Date, DateTime,

Also available in: Unified diff