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:
parent
190e817fb8
commit
c583ad4367
@ -49,11 +49,17 @@ public class ToNumber implements Function {
|
||||
if (args[0] instanceof Number) {
|
||||
return args[0];
|
||||
} else {
|
||||
String s = args[0].toString();
|
||||
try {
|
||||
return Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return new EvalError("Cannot parse to number");
|
||||
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) {
|
||||
return new EvalError("Cannot parse to number");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user