创建德国货币格式

Create German currency format

我打算在 Android 中创建一个德国货币格式,我就是无法使用千位、百万位分隔符。这是我到目前为止所做的:

String bill_subtotal = String.format("%.2f", bill_amount);
txtSubtotal = (TextView) findViewById(R.id.txtSubtotal);
txtSubtotal.setText(String.valueOf(bill_subtotal).replace(',', '.'));

以上只做这样的值:60000.50变成60000,50
我想让它成为 60.000,50

有没有办法做到这一点?

我的解决方案是,

public static String formatGermanCurrency(double number) {
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY);
    nf.setMaximumFractionDigits(2);
    nf.setMinimumFractionDigits(2);
    return nf.format(number);
}