How to format double value for a given locale and number of decimal places?

后端 未结 4 1656
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 15:27

How can I use NumberFormat to format a double value for a given Locale (default locale is sufficient) and for a given number of decima

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 15:51

    You could use something like

    DecimalFormat formatter = (DecimalFormat) DecimalFormat.getInstance();
    formatter.applyPattern("#,###,##0.00");
    formatter.format(yourDoubleHere)
    

提交回复
热议问题