新增方法
This commit is contained in:
parent
a9dac9f91b
commit
a9f1a8fb14
@ -1,6 +1,5 @@
|
||||
package com.cm.common.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@ -47,6 +46,26 @@ public class RegexUtil {
|
||||
* 时间戳格式
|
||||
*/
|
||||
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]))*$");
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private static final Pattern PATTERN_YYYY_MM_DD = Pattern.compile("^(\\d{4})(0\\d{1}|1[0-2])(0\\d{1}|[1-2][0-9]|3[0-1])$");
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private static final Pattern PATTERN_YYYY_MM_DD_HH_MM_SS = Pattern.compile("^(\\d{4})(0\\d{1}|1[0-2])(0\\d{1}|[1-2][0-9]|3[0-1])([0-1][0-9]|(2[0-3]))([0-5][0-9])([0-5][0-9])$");
|
||||
/**
|
||||
* 时间戳(毫秒)
|
||||
*/
|
||||
private static final Pattern PATTERN_YYYY_MM_DD_HH_MM_SS_ZZZ = Pattern.compile("^(\\d{4})(0\\d{1}|1[0-2])(0\\d{1}|[1-2][0-9]|3[0-1])([0-1][0-9]|(2[0-3]))([0-5][0-9])([0-5][0-9])(\\d{3})$");
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private static final Pattern PATTERN_HH_MM_SS = Pattern.compile("^([0-1][0-9]|(2[0-3]))([0-5][0-9])([0-5][0-9])$");
|
||||
/**
|
||||
* 时间戳(毫秒)
|
||||
*/
|
||||
private static final Pattern PATTERN_HH_MM_SS_ZZZ = Pattern.compile("^([0-1][0-9]|(2[0-3]))([0-5][0-9])([0-5][0-9])(\\d{3})$");
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
@ -159,6 +178,55 @@ public class RegexUtil {
|
||||
public static boolean isDatetime(String input) {
|
||||
return PATTERN_DATETIME.matcher(input).matches();
|
||||
}
|
||||
/**
|
||||
* 判断时间时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isYyyyMmDd(String input) {
|
||||
return PATTERN_YYYY_MM_DD.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isYyyyMmDdHhMmSs(String input) {
|
||||
return PATTERN_YYYY_MM_DD_HH_MM_SS.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isYyyyMmDdHhMmSsZzz(String input) {
|
||||
return PATTERN_YYYY_MM_DD_HH_MM_SS_ZZZ.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isHhMmSs(String input) {
|
||||
return PATTERN_HH_MM_SS.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间时间戳
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isHhMmSsZzz(String input) {
|
||||
return PATTERN_HH_MM_SS_ZZZ.matcher(input).matches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断身份证
|
||||
|
Loading…
Reference in New Issue
Block a user