NumberFormatter e = new NumberFormatter (NumberFormat.getNumberInstance ());
JFormattedTextFiel textField_4 = new JFormattedTextField (e);
When I enter 0-999 numbers for these operations, no problem.
but enter 1000 and above, this problem occurs : it will 1000 formatted as 1,000 .
so in 1000 after converting to integer will be operational when the problem occurs because the 1000 can not be converted to an integer , more than a comma .
So I wrote a function to remove this comma · · but found or not. Great God seeking solutions
public String limits () {
char str [] = new char [string.length ()];
char strr [] = new char [string.length ()];
String s = null;
int j = 0;
string.getChars (0, string.length (), str, 0);
for (int i = 0; i
strr [j] = str [i];
j + +;
}
}
s = s.valueOf (strr);
return s;
}
------ Solution ----------------------------------- ---------
String s = "1,000";
System.out.println(s.replaceAll(",", ""));
------ For reference only ----------------------- ----------------
how nobody does · ·
------ For reference only ----------- ----------------------------
hey Xueyibujing ah · · · · Thank you so much has been resolved
没有评论:
发表评论