Skip to content

Commit

Permalink
updated number parse bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PGWelch committed Feb 12, 2015
1 parent e211ed0 commit 6fa0aa4
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,18 @@ public static Object convertToMe(ODLColumnType convertToMe, Object other, ODLCol
}

try {
// return Double.parseDouble((String) sOther);

// Changed from parseDouble to NumberFormat as this takes locale into account
// and don't load correctly otherwise on French computers.
NumberFormat nf = NumberFormat.getInstance();
double number = nf.parse((String) sOther).doubleValue();
// Test if we have a . in the number and if so, use java's parsedouble which always uses .
double number=0;
if(sOther.indexOf(".")!=-1){
number = Double.parseDouble(sOther);
}else{
// If not, use the number format which takes account of localisation and will use commas in the correct country.
NumberFormat nf = NumberFormat.getInstance();
number = nf.parse((String) sOther).doubleValue();
return number;
}

return number;
} catch (Throwable e) {
return null;
Expand Down

0 comments on commit 6fa0aa4

Please sign in to comment.