【问题标题】:Create German currency format创建德国货币格式
【发布时间】:2017-04-06 09:29:10
【问题描述】:

我要在 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

有没有办法做到这一点?

【问题讨论】:

  • 你试过我的答案了吗?
  • 我会的,但是我现在离开电脑,我会尽快更新,谢谢!

标签: android numbers currency


【解决方案1】:

我的解决办法是,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-24
    • 1970-01-01
    相关资源
    最近更新 更多