管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-28 f516a5d4cdc4995a2a2482b77f9fdf0e58fde644
src/main/java/com/lf/server/helper/StringHelper.java
@@ -1,5 +1,7 @@
package com.lf.server.helper;
import com.lf.server.entity.all.StaticData;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
@@ -26,10 +28,17 @@
    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");
    /**
     * 判断字符串,是否为数字
     *
     * @param str
     * @return
     */
    public static boolean isNumber(String str) {
        return NUMBER_PATTERN.matcher(str).matches();
@@ -42,9 +51,6 @@
    /**
     * 字符串转为日期
     *
     * @param str
     * @return
     */
    public static Date parseDate(String str) {
        try {
@@ -56,9 +62,6 @@
    /**
     * 字符串转为日期时间
     *
     * @param str
     * @return
     */
    public static Date parseTime(String str) {
        try {
@@ -70,9 +73,6 @@
    /**
     * 判断值是否为日期格式
     *
     * @param strDate
     * @return
     */
    public static boolean isDate(String strDate) {
        Matcher m = datePattern.matcher(strDate);
@@ -81,24 +81,47 @@
    }
    /**
     * 字符串,是否为空
     *
     * @param str
     * @return
     * 字符串,是否为null 或 ""
     */
    public static boolean isEmpty(String str) {
    public static boolean isNull(String str) {
        return null == str || str.length() == 0;
    }
    /**
     * 首字母大写
     *
     * @param str
     * @return
     * 字符串,是否为空null和空格
     */
    public static String capitalize(String str) {
        String f = str.charAt(0) + "";
    public static boolean isEmpty(String str) {
        return str == null || "".equals(str.trim());
    }
        return f.toUpperCase() + str.substring(1);
    /**
     * 获取 like 字符串
     */
    public static String getLikeStr(String name) {
        return StringHelper.isEmpty(name) ? null : "%" + name.trim() + "%";
    }
    /**
     * 首字母大写
     */
    public static String firstCharToUpperCase(String str) {
        return str.substring(0, 1).toUpperCase() + str.substring(1);
    }
    /**
     * 首字母小写
     */
    public static String firstCharToLowerCase(String str) {
        return str.substring(0, 1).toLowerCase() + str.substring(1);
    }
    /**
     * 校验密码是/否合法
     *
     * @param pwd 密码
     * @return 是/否合法
     */
    public static boolean checkPwdValid(String pwd) {
        return Pattern.matches(StaticData.PWD_REG, pwd);
    }
}