Issue 537 - Try to convert to Long first before converting to Double. Matches behavior on import.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2446 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-02-26 17:27:00 +00:00
parent 190e817fb8
commit c583ad4367

View File

@ -49,7 +49,12 @@ public class ToNumber implements Function {
if (args[0] instanceof Number) {
return args[0];
} else {
String s = args[0].toString();
String s = args[0].toString().trim();
if (s.length() > 0) {
try {
return Long.parseLong(s);
} catch (NumberFormatException e) {
}
try {
return Double.parseDouble(s);
} catch (NumberFormatException e) {
@ -57,6 +62,7 @@ public class ToNumber implements Function {
}
}
}
}
return null;
}