输入看起来像8.7000000
,我想将其格式化为8.70 EUR
. 我考虑过使用这个DecimalFormat
类:
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);
结果是8.7 EUR
。如何告诉格式化程序在 之后有两位数.
?