Doubles, commas and dots

后端 未结 7 1180
深忆病人
深忆病人 2020-12-14 09:03

I\'m making an Android Java program which is taking double values from the user. If I run the program on the computer, it works great because of the locale of my computer, E

7条回答
  •  無奈伤痛
    2020-12-14 09:31

    using DecimalFormatSymbols.getInstance() will produce the default locale's correct symbols, so you will get it right for any platform you run on.

    DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance());
    

提交回复
热议问题