Doubles, commas and dots

后端 未结 7 1201
深忆病人
深忆病人 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:38

    Use one of the other constructors of DecimalFormat:

    new DecimalFormat("#.#", new DecimalFormatSymbols(Locale.US))
    

    And then try and parse it using both separators.

提交回复
热议问题