如何把国外的网站在国内做镜像营销推广工作内容
此工具类暂时包含如下功能:
- isEmpty()判断字符串是否为空
- subSpecifiedString()判断字符串是否超出指定长度,超出则截取到指定长度
- yearMonthToDate()将年月的字符串转成年月日格式
- yearMonthToDateTime()将年月的字符串转成年月日时分秒格式
package com.zkdj.applet.common;import lombok.extern.slf4j.Slf4j;import java.util.regex.Pattern;/*** 类描述 -> 自定义字符串工具类** @Author: ywz* @Date: 2024/09/16*/
@Slf4j
public class StringUtils {/*** 方法描述 -> 判断字符串是否为空** @param str 字符串* @Author: ywz* @Date: 2024/09/16*/public static boolean isEmpty(String str) {return str == null || str.isEmpty();}/*** 方法描述 -> 判断字符串是否超出指定长度,超出则截取到指定长度** @param str 字符串* @param length 指定长度* @Author: ywz* @Date: 2024/09/16*/public static String subSpecifiedString(String str, int length) {return str.length() > length ? str.substring(0, length) : str;}/*** 方法描述 -> 将年月的字符串转成年月日格式** @param yearMonth 年月* @Author: ywz* @Date: 2024/09/16*/public static String yearMonthToDate(String yearMonth) {Pattern pattern = Pattern.compile("^[0-9]{4}-(0[1-9]|1[0-2])$");if (!pattern.matcher(yearMonth).matches()) {log.error("日期格式错误");return null;}return yearMonth + "-01";}/*** 方法描述 -> 将年月的字符串转成年月日时分秒格式** @param yearMonth 年月* @Author: ywz* @Date: 2024/09/16*/public static String yearMonthToDateTime(String yearMonth) {Pattern pattern = Pattern.compile("^[0-9]{4}-(0[1-9]|1[0-2])$");if (!pattern.matcher(yearMonth).matches()) {log.error("日期格式错误");return null;}return yearMonth + "-01 00:00:00";}
}