我格式化两位小数的值:在log.d中的edAmount.setText(String.format("%.2f", balancePayment));
它显示格式化的值:
"Log.d("String format:",String.format("%.2f", balancePayment));
D/String format:: 22.00
但编辑文字显示“22.0”是什么原因?
NumberFormat formatter = NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String output = formatter.format(balancePayment);
edAmount.setText(output);