|
@@ -23,8 +23,8 @@ public class CoreUtil {
|
|
|
if (StringUtil.isEmpty(ageStr)) {
|
|
|
return 20.0;
|
|
|
}
|
|
|
- // 全是整形数字,当成年龄处理
|
|
|
- if (numbersOnly(ageStr)) {
|
|
|
+ // 数值,当成年龄处理
|
|
|
+ if (isNumbers(ageStr)) {
|
|
|
return Double.parseDouble(ageStr);
|
|
|
}
|
|
|
// 20日
|
|
@@ -81,6 +81,17 @@ public class CoreUtil {
|
|
|
return str.matches(regex);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断字符串是否数值(正)
|
|
|
+ *
|
|
|
+ * @param str
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static boolean isNumbers(String str) {
|
|
|
+ String regex = "[0-9]+|([0-9]+\\.)+[0-9]*|[0-9]*(\\.[0-9]+)+";
|
|
|
+ return str.matches(regex);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断年龄字符串:xx月
|
|
|
*
|