| | |
| | | */ |
| | | public static final SimpleDateFormat YMDHMS_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | /** |
| | | * 格式化当前系统日期 3 |
| | | */ |
| | | public static final SimpleDateFormat YMD__FORMAT = new SimpleDateFormat("yyyyMMdd_"); |
| | | |
| | | /** |
| | | * 格式化当前系统日期 4 |
| | | */ |
| | | public static final SimpleDateFormat YMD_HM_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmm"); |
| | | |
| | | public static final double D1024 = 1024.0; |
| | | |
| | | /** |
| | | * 判断字符串,是否为数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static boolean isNumber(String str) { |
| | | return NUMBER_PATTERN.matcher(str).matches(); |
| | |
| | | |
| | | /** |
| | | * 字符串转为日期 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static Date parseDate(String str) { |
| | | try { |
| | |
| | | |
| | | /** |
| | | * 字符串转为日期时间 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static Date parseTime(String str) { |
| | | try { |
| | |
| | | |
| | | /** |
| | | * 判断值是否为日期格式 |
| | | * |
| | | * @param strDate |
| | | * @return |
| | | */ |
| | | public static boolean isDate(String strDate) { |
| | | Matcher m = datePattern.matcher(strDate); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 字符串,是否为null或"" |
| | | * |
| | | * @param str |
| | | * @return |
| | | * 字符串,是否为null 或 "" |
| | | */ |
| | | public static boolean isNull(String str) { |
| | | return null == str || str.length() == 0; |
| | |
| | | |
| | | /** |
| | | * 字符串,是否为空null和空格 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static boolean isEmpty(String str) { |
| | | return str == null || "".equals(str.trim()); |
| | | } |
| | | |
| | | /** |
| | | * 获取 like 字符串 |
| | | */ |
| | | public static String getLikeStr(String name) { |
| | | return StringHelper.isEmpty(name) ? null : "%" + name.trim() + "%"; |
| | | } |
| | | |
| | | /** |
| | | * 首字母大写 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String capitalize(String str) { |
| | | return String.valueOf(str.charAt(0)).toUpperCase() + str.substring(1); |
| | |
| | | |
| | | /** |
| | | * 字节单位换算 |
| | | * |
| | | * @param byteNumber |
| | | * @return |
| | | */ |
| | | public static String formatByte(long byteNumber) { |
| | | double kbNumber = byteNumber / D1024; |