How to format Double with dot?

前端 未结 3 599
挽巷
挽巷 2020-12-24 01:39

How do I format a Double with String.format to String with a dot between the integer and decimal part?

String s = String.format(\"%.2f\", price)         


        
3条回答
  •  囚心锁ツ
    2020-12-24 02:15

    If it works the same as in PHP and C#, you might need to set your locale somehow. Might find something more about that in the Java Internationalization FAQ.

提交回复
热议问题