新增时间戳正则判断
This commit is contained in:
parent
288fdc5c61
commit
4477561d92
@ -43,6 +43,10 @@ public class RegexUtil {
|
||||
* 日期格式
|
||||
*/
|
||||
private static final Pattern PATTERN_DATE = Pattern.compile("^(\\d{4})[-\\/](\\d{1}|0\\d{1}|1[0-2])([-\\/](\\d{1}|0\\d{1}|[1-2][0-9]|3[0-1]))*$");
|
||||
/**
|
||||
* 时间戳格式
|
||||
*/
|
||||
private static final Pattern PATTERN_DATETIME = Pattern.compile("^(\\d{4})[-\\/](\\d{1}|0\\d{1}|1[0-2])([-\\/](\\d{1}|0\\d{1}|[1-2][0-9]|3[0-1]))*(\\s+)([0-1][0-9]|(2[0-3])):([0-5][0-9])(:([0-5][0-9]))*$");
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
@ -142,6 +146,16 @@ public class RegexUtil {
|
||||
return PATTERN_DATE.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDatetime(String input) {
|
||||
return PATTERN_DATETIME.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断身份证
|
||||
*
|
||||
|
@ -161,6 +161,11 @@ public class AnnotationUtil {
|
||||
throw new ParamsException(String.format("%s格式非日期格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("datetime", verifyType)) {
|
||||
if (!RegexUtil.isDatetime(value)) {
|
||||
throw new ParamsException(String.format("%s格式非时间戳格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("identity", verifyType)) {
|
||||
if (!RegexUtil.isIdentity(value)) {
|
||||
throw new ParamsException(String.format("%s格式非身份证格式", name));
|
||||
|
Loading…
Reference in New Issue
Block a user