How to Automatically add thousand separators as number is input in EditText

后端 未结 13 2033
花落未央
花落未央 2020-11-27 05:21

Im creating a convertor application, I want to set the EditText so that when the user is inputting the number to be converted, a thousand separator (,) should be added autom

13条回答
  •  死守一世寂寞
    2020-11-27 05:40

      public static String doubleToStringNoDecimal(double d) {
            DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);;
            formatter .applyPattern("#,###");
            return formatter.format(d);
        }
    

提交回复
热议问题