How can I format a String number to have commas in android Edit Field

后端 未结 8 1834
盖世英雄少女心
盖世英雄少女心 2020-12-07 18:27

For what function I can use in android to display the number into different formats.

For eg: If I enter 1000 then it should display like this 1,000. If I enter 1000

8条回答
  •  既然无缘
    2020-12-07 19:05

    You can use Numberformat

    public static double getNumberByString(String s) throws ParseException {
        return NumberFormat.getInstance(Locale.getDefault()).parse(s).doubleValue();
    }
    

提交回复
热议问题