|
@@ -656,12 +656,16 @@ public class CoreUtil {
|
|
|
if (ageStr.endsWith("岁")) {
|
|
|
return Double.parseDouble(ageStr.substring(0, ageStr.length() - 1));
|
|
|
}
|
|
|
- // 3岁7个月
|
|
|
+ // 3岁7个月 | 3岁7月
|
|
|
if (ageSuiYue(ageStr)) {
|
|
|
String[] ageArr = new String[2];
|
|
|
int indexSui = ageStr.indexOf("岁");
|
|
|
ageArr[0] = ageStr.substring(0, indexSui);
|
|
|
- ageArr[1] = ageStr.substring(indexSui + 1, ageStr.indexOf("个月"));
|
|
|
+ if (ageStr.indexOf("个月") > -1) { // 3岁7个月
|
|
|
+ ageArr[1] = ageStr.substring(indexSui + 1,ageStr.indexOf("个月"));
|
|
|
+ } else { // 3岁7月
|
|
|
+ ageArr[1] = ageStr.substring(indexSui + 1,ageStr.indexOf("月"));
|
|
|
+ }
|
|
|
return Double.parseDouble(ageArr[0]) + getHalfUp(Double.parseDouble(ageArr[1]) / 12);
|
|
|
}
|
|
|
// 1.08月 | .11月 | 3月
|
|
@@ -732,7 +736,7 @@ public class CoreUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public static boolean ageSuiYue(String str) {
|
|
|
- String regex = "^[0-9]{1,3}岁[0-9]{1,2}个月$";
|
|
|
+ String regex = "^[0-9]{1,3}岁[0-9]{1,2}个{0,1}月$";
|
|
|
return str.matches(regex);
|
|
|
}
|
|
|
|