Doubles, commas and dots

后端 未结 7 1175
深忆病人
深忆病人 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:44
    public static Double parseDoubleTL(String value){
        DecimalFormat df =  new DecimalFormat("#.#", new DecimalFormatSymbols(new Locale("tr_TR")));
        Double doublePrice = 0.0;
        try {
            doublePrice =  df.parse(value).doubleValue();
        } catch (ParseException e) {
            Log.w(MainActivity.TAG,"Couldnt parse TL. Error is "+e.toString());
        }
        return doublePrice;
    }
    
    0 讨论(0)
提交回复
热议问题