| | |
| | | /** |
| | | * 数字正则 |
| | | */ |
| | | public static final Pattern NUMBER_PATTERN = Pattern.compile("^[-\\+]?[\\d]*[.]?[\\d]*$"); |
| | | public static final Pattern NUMBER_PATTERN = Pattern.compile("-?\\d+(\\.\\d+)?"); |
| | | |
| | | /** |
| | | * 格式化当前系统日期 1 |
| | |
| | | public static final SimpleDateFormat YMD_HM_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmm"); |
| | | |
| | | /** |
| | | * 判断字符串,是否为数字 |
| | | * 判断字符串,是否为整数 |
| | | */ |
| | | public static boolean isNumber(String str) { |
| | | return NUMBER_PATTERN.matcher(str).matches(); |
| | | public static boolean isInteger(String str) { |
| | | return str != null && str.matches("[0-9]+"); |
| | | } |
| | | |
| | | /** |
| | | * 判断字符串,是否为浮点数 |
| | | */ |
| | | public static boolean isNumeric(String str) { |
| | | return str != null && str.matches("-?\\d+(\\.\\d+)?"); |
| | | } |
| | | |
| | | /** |
| | | * 判断字符串,是否为浮点数 |
| | | */ |
| | | public static boolean isNumeric2(String str) { |
| | | return str != null && NUMBER_PATTERN.matcher(str).matches(); |
| | | } |
| | | |
| | | /** |