double
を小数点以下2桁にフォーマットするにはどうすればよいですか? Decimalformat
またはstring.format
が期待される出力を与えていない:Androidの2桁の小数形式
DecimalFormat precision = new DecimalFormat("0.00");
s = mylist.get(0).getHARUALTAESGE();
double hramount = Double.parseDouble(s);
String rb = rebatespin.getSelectedItem().toString();
//below one
double rebamount = (Double.parseDouble(s) * Double.parseDouble(rb.replace("%", "")));
rebateamount.setText(precision.format(rebamount));
double hualr=(hramount-rebamount);
//below other one
haulageprice.setText(String.format("%.2f", hualr));
あなたはどのような出力が表示されません? –
2桁以上の小数点が表示されます – neutr0n
コードの詳細を表示してください –