程序包 cn.starrys.util
类 Utility
- java.lang.Object
-
- cn.starrys.util.Utility
-
public class Utility extends java.lang.Object
-
-
构造器概要
构造器 构造器 说明 Utility()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static intconvertHoursToSeconds(int hour)将小时转换为秒static java.sql.TimestampcurrentTimestamp()获取当前时间戳static booleanisEmpty(java.lang.String str)判断是否为空static java.lang.Stringmd5(java.lang.String text)计算字符串的MD5static booleannotEmpty(java.lang.String str)判断是否不为空static java.lang.StringrequestGetIp(javax.servlet.http.HttpServletRequest request)获取IP地址
若使用Tomcat10及以上则应该导这个包:jakarta.servlet.http.HttpServletRequeststatic java.lang.Stringuuid()获取一串随机的32位UUID
-
-
-
方法详细资料
-
uuid
public static java.lang.String uuid()
获取一串随机的32位UUID- 返回:
- 一串32位长度的UUID
-
convertHoursToSeconds
public static int convertHoursToSeconds(int hour)
将小时转换为秒- 参数:
hour- 小时- 返回:
- 传入小时的秒数
-
isEmpty
public static boolean isEmpty(java.lang.String str)
判断是否为空- 参数:
str- 进行判断的字符串- 返回:
- 为 null 或空字符串为 true,不为空为 false
-
notEmpty
public static boolean notEmpty(java.lang.String str)
判断是否不为空- 参数:
str- 进行判断的字符串- 返回:
- 为 null 或空字符串为 false,不为空为 true
-
currentTimestamp
public static java.sql.Timestamp currentTimestamp()
获取当前时间戳- 返回:
- Timestamp类型的当前时间
-
md5
public static java.lang.String md5(java.lang.String text)
计算字符串的MD5- 参数:
text- 要计算的字符串(若为空则返回 "")- 返回:
text的MD5
-
requestGetIp
public static java.lang.String requestGetIp(javax.servlet.http.HttpServletRequest request)
获取IP地址
若使用Tomcat10及以上则应该导这个包:jakarta.servlet.http.HttpServletRequest- 参数:
request- HttpServletRequest- 返回:
- IP地址
-
-