How to specify decimal delimiter

前端 未结 3 403
遥遥无期
遥遥无期 2021-01-26 01:26

I have a fairly simple problem. I am getting real-number input like6.03, but that gives me errors. If I change it to 6,03, it\'s ok. I, however, can\'t

3条回答
  •  温柔的废话
    2021-01-26 02:02

    You're probably running into Locale issues. You can use java.text.NumberFormat for parsing.

    NumberFormat format = NumberFormat.getInstance(Locale.US);
    Number number = format.parse("6.03");
    double d = number.doubleValue();
    

提交回复
热议问题