Invalid double in converting String to Double

前端 未结 2 1570
孤城傲影
孤城傲影 2021-01-26 06:05

i get a NumberFormatException : invalid double \"111,000,000\" in this line of code :

double SalePotential = Double.valueOf(EtPotential.getText().toString());
<         


        
2条回答
  •  臣服心动
    2021-01-26 06:29

    Use replace function to replace all occurences of ,

         String  s= EtPotential.getText().toString();
         s = s.replace(",", ""); 
         try
         {
           double SalePotential = Double.parseDouble(s);
         }catch(NumberFormatException e)
         {
             e.printStackTrace();
         }
    

提交回复
热议问题