@Component public class Utils extends Object
| 构造器和说明 |
|---|
Utils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Object |
covertStr(String str,
Class<?> tClass)
转换字符串
|
static String |
getIp()
获取当前ip
|
static String |
getIpAddr(javax.servlet.http.HttpServletRequest request)
获取用户真实IP地址,不使用request.getRemoteAddr()的原因是有可能用户使用了代理软件方式避免真实IP地址,
可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值
|
static Date |
getNowDate()
获取当前格式化时间
|
static String |
getStringFromInputStream(InputStream inputStream)
从输入流读取完整字符串
|
static boolean |
isNumeric(String str)
利用正则表达式判断字符串是否是数字
|
static void |
main(String[] args) |
static org.springframework.data.domain.Sort |
sortAttr(Map<String,String> tableMap,
String sorterBy)
表格排序
|
static String |
stringToTime(String date)
日期字符串转String型Time
|
static Date |
timeToDate(String time)
time时间戳转Date
|
public static void main(String[] args) throws IOException
IOExceptionpublic static Date getNowDate()
public static String getStringFromInputStream(InputStream inputStream) throws IOException
inputStream - inputStreamIOException - IOExceptionpublic static String getIp()
public static String stringToTime(String date)
date - date字符串public static org.springframework.data.domain.Sort sortAttr(Map<String,String> tableMap, String sorterBy)
tableMap - tableMapsorterBy - 默认按此属性排序public static boolean isNumeric(String str)
str - strpublic static String getIpAddr(javax.servlet.http.HttpServletRequest request)
Copyright © 2022. All Rights Reserved.