【发布时间】:2011-12-15 20:11:22
【问题描述】:
如何验证用户输入仅包含 5 位数字和 2 位小数。我使用下面的代码来检查 5 位数字,但是如何检查 2 位小数。
if (!id.equals("")) {
try {
Integer.parseInt(id);
if (id.length() <= 5) {
return true;
}
} catch (NumberFormatException nfe) {
return false;
}
}
【问题讨论】:
-
您可能对JFormattedTextField感兴趣。
标签: java swing format double decimal