How to format a Float Value with the device currency format?

后端 未结 4 1963
执念已碎
执念已碎 2021-01-31 07:30

I have an app that prints a calculated money value and I want to display that value with the default currency format.

For example in Europe you would write:

1.

4条回答
  •  爱一瞬间的悲伤
    2021-01-31 08:17

    Check out DecimalFormat.

    It has a variety of features designed to make it possible to parse and format numbers in any locale, including support for Western, Arabic, or Indic digits. It also supports different flavors of numbers, including integers ("123"), fixed-point numbers ("123.4"), scientific notation ("1.23E4"), percentages ("12%"), and currency amounts ("$123"). All of these flavors can be easily localized.

提交回复
热议问题