Decimal format for another Decimal format on Android -


i'm having trouble formatting decimal value format (8487.0) format. "8.48".

i have tried solution of other issues posted here did not succeed.

example:

double n1 = double.parsedouble (string.valueof (8487.0)); decimalformat dec = new decimalformat ("#. ##"); string credits = dec.format (n1);   log.d (tag, "test" + credits); 

currently has output this: 8487

any welcomed, thanks.

you can use string format

string answer = string.format("%.2f", (8487.0 / 1000));         log.d(tag, answer); //8.49 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -