[英]In Java, convert the dot to comma in DecimalFormat replace method
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if( editText != null)
{
if(editText.getText().length() > 0){
String TL = null;
DecimalFormat formatter = new DecimalFormat("#,###");
String ss = "";
try{
ss = editText.getText().toString();
ss = ss.replace(".", "");
ss = ss.replace(",", "");
Long number = Long.parseLong(ss);
ss = formatter.format(number);
}catch(Exception e){
ss = e.toString();
}
changeText(editText,ss);
}
editText.setSelection(editText.length());
}
}
when the user enter the value like 50000 answer is 50.000 in editText. 当用户在editText中输入类似50000的值时,答案是50.000。 But, I dont want to dot.
但是,我不想点。 I want to comma like 50,000.
我想用50,000作为逗号。 How can I do it ?
我该怎么做 ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.