How do I format a number in Java?

前端 未结 9 1874
自闭症患者
自闭症患者 2020-11-22 05:10

How do I format a number in Java?
What are the "Best Practices"?

Will I need to round a number before I format it?

32.302342

9条回答
  •  醉梦人生
    2020-11-22 05:32

    As Robert has pointed out in his answer: DecimalFormat is neither synchronized nor does the API guarantee thread safety (it might depend on the JVM version/vendor you are using).

    Use Spring's Numberformatter instead, which is thread safe.

提交回复
热议问题