java.lang.NumberFormatException: For input string: “20,475.00”

后端 未结 4 864
北荒
北荒 2021-01-13 19:58

i am trying to get the running balance of my system. To do it, i get the sum of all numbers in the jtable from column AMOUNT and subtract the sum to the value inside the txt

4条回答
  •  迷失自我
    2021-01-13 20:51

    Since Float.parseFloat() and Float.valueOf() always will assume that the number is in your local format, here's a short example how to do localized parsing if your locale does not match the number format you're getting.

    String str = "20,475.00";
    NumberFormat nf = NumberFormat.getInstance(Locale.US); // Looks like a US format
    float f = nf.parse(str).floatValue();
    

提交回复
热议问题