程序包 cn.starrys.util

类 Utility


  • public class Utility
    extends java.lang.Object
    • 构造器概要

      构造器 
      构造器 说明
      Utility()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static int convertHoursToSeconds​(int hour)
      将小时转换为秒
      static java.sql.Timestamp currentTimestamp()
      获取当前时间戳
      static boolean isEmpty​(java.lang.String str)
      判断是否为空
      static java.lang.String md5​(java.lang.String text)
      计算字符串的MD5
      static boolean notEmpty​(java.lang.String str)
      判断是否不为空
      static java.lang.String requestGetIp​(javax.servlet.http.HttpServletRequest request)
      获取IP地址
      若使用Tomcat10及以上则应该导这个包:jakarta.servlet.http.HttpServletRequest
      static java.lang.String uuid()
      获取一串随机的32位UUID
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Utility

        public Utility()
    • 方法详细资料

      • 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地址