localization - (android) decimalformat, uses comma in place of fullstop while formatting with "#.##" -


i developing android app want format double number #.##, have done using below code.

double bmi = ((fweight)/(dheight*dheight)); decimalformat df = new decimalformat("0.00"); string sbmi = df.format(bmi); 

while testing when language of hardware set english(default language), works fine, example if bmi 2497.227216676656 , formats sbmi 2497.23 , if language selected french formats 2497,23. in place of dot, comma being used crashing app!!!

what reason this?

try this:

double bmi = ((fweight)/(dheight*dheight)); decimalformat df = new decimalformat("0.00"); decimalformatsymbols dfs = new decimalformatsymbols(); dfs.setdecimalseparator('.'); df.setdecimalformatsymbols(dfs); string sbmi = df.format(bmi); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -