The input looks like 8.7000000
and I want to format it to look like 8.70 EUR
.
I considered using the DecimalFormat
class:
Double number = Double.valueOf(text);
DecimalFormat dec = new DecimalFormat("#.## EUR");
String credits = dec.format(number);
TextView tt = (TextView) findViewById(R.id.creditsView);
tt.setText(credits);
The result is 8.7 EUR
. How can I tell the formatter to have two digits after the .
?