Index: CoerceToLong.java
===================================================================
--- CoerceToLong.java	(revision 1404)
+++ CoerceToLong.java	(revision 1405)
@@ -3,59 +3,108 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.tools.dataTypes.impl.coercion;
 
+import java.text.NumberFormat;
+import java.text.ParsePosition;
+import java.util.Locale;
 import org.gvsig.tools.dataTypes.CoercionException;
-import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
+import org.gvsig.tools.dataTypes.DataTypesManager.CoercionWithLocale;
 
-public class CoerceToLong implements Coercion {
+public class CoerceToLong implements CoercionWithLocale {
 
-	public Object coerce(Object value) throws CoercionException {
-    	if( value == null ) {
-    		return null;
-    	}
-		try {
-			if( ! (value instanceof Long) ) {
-				if( value instanceof Number ) {
-					value = new Long(((Number)value).longValue());
-				} else {
-					String s = value.toString();
-                                        if( s == null ) {
-                                            return null;
-                                        }
-                                        s = s.trim().toLowerCase();
-                                        if( s.length()==0 ) {
-                                            return null;
-                                        }
-					if( s.startsWith("0x")) {
-						value = Long.valueOf(s.substring(2), 16);
-					} else {
-					    value = Long.valueOf(s);
-					}
-				}
-			}
-			return value;
-		} catch(Exception e) {
-			throw new CoercionException(e); 
-		}
-	}
+    @Override
+    public Object coerce(Object value) throws CoercionException {
+        if (value == null) {
+            return null;
+        }
+        try {
+            if (!(value instanceof Long)) {
+                if (value instanceof Number) {
+                    value = ((Number) value).longValue();
+                } else {
+                    String s = value.toString();
+                    if (s == null) {
+                        return null;
+                    }
+                    s = s.trim().toLowerCase();
+                    if (s.length() == 0) {
+                        return null;
+                    }
+                    if (s.startsWith("0x")) {
+                        value = Long.valueOf(s.substring(2), 16);
+                    } else {
+                        try {
+                            value = Long.valueOf(s);
+                        } catch (NumberFormatException ex) {
+                            value = Float.valueOf(s);
+                            value = ((Number) value).longValue();
+                        }
+                    }
+                }
+            }
+            return value;
+        } catch (Exception e) {
+            throw new CoercionException(e);
+        }
+    }
 
+    @Override
+    public Object coerce(Object value, Locale locale) throws CoercionException {
+        if (value == null) {
+            return null;
+        }
+        try {
+            if (!(value instanceof Long)) {
+                if (value instanceof Number) {
+                    value = ((Number) value).longValue();
+                } else {
+                    String s = value.toString();
+                    if (s == null) {
+                        return null;
+                    }
+                    s = s.trim().toLowerCase();
+                    if (s.length() == 0) {
+                        return null;
+                    }
+                    if (s.startsWith("0x")) {
+                        value = Long.valueOf(s.substring(2), 16);
+                    } else {
+                        try {
+                            value = Long.valueOf(s);
+                        } catch (NumberFormatException ex) {
+                            ParsePosition p = new ParsePosition(0);
+                            NumberFormat nf = NumberFormat.getInstance(locale);
+                            Number num = nf.parse(s, p);
+                            if (p.getErrorIndex() > 0 || p.getIndex() < s.length()) {
+                                throw new CoercionException("can't coerce to double with locale " + locale.getLanguage());
+                            }
+                            value = ((Number) num).longValue();
+                        }
+                    }
+                }
+            }
+            return value;
+        } catch (Exception e) {
+            throw new CoercionException(e);
+        }
+    }
+
 }
