public class CommonUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_FORMAT
常见的日期格式
|
static String |
DATE_FORMAT_SHORT |
static String |
DATE_FORMAT_SHORTER |
| 构造器和说明 |
|---|
CommonUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
containsIgnoreCase(String a,
String b)
输入 a,看 a 里面是否包含另一个字符串 b,忽略大小写。
|
static String |
formatDate(Date date)
对输入的时间进行格式化,采用格式 yyyy-MM-dd HH:mm:ss
|
static String |
formatDateShorter(Date date)
对输入的时间进行格式化,采用格式 YYYY-MM-dd HH:MM
|
static String |
getRandomString(int length)
生成指定长度的随机字符,可能包含数字
|
static boolean |
isEmptyString(String str)
是否空字符串
|
static boolean |
isNull(Collection<?> collection)
判断 collection 是否为空
|
static boolean |
isNull(Map<?,?> map)
判断 map 是否有意义
|
static boolean |
isNull(Object[] arr)
判断数组是否为空
|
static String |
now()
返回当前时间的 YYYY-MM-dd HH:MM:ss 字符串类型
|
static String |
now(String format)
返回当前时间,并对当前时间进行格式化
|
static Date |
Objet2Date(Object obj)
支持任意对象转换为日期类型
|
static String |
regMatch(String regexp,
String str)
使用正则的快捷方式
|
static String |
regMatch(String regexp,
String str,
int groupIndex)
使用正则的快捷方式。
|
static String[] |
regMatchAll(String regexp,
String str)
返回所有匹配项
|
static String |
repeatStr(String str,
String div,
int repeat)
重复字符串 repeat 次并以 div 分隔
|
static SimpleDateFormat |
simpleDateFormatFactory(String format)
对输入的时间进行格式化 有 SimpleDateFormat 缓存 格式化的另外一种方法
new SimpleDateFormat(format).format(System.currentTimeMillis());
返回 SimpleDateFormat 的工厂函数 |
static String[] |
split(String str)
将一个字符串分隔为字符串数组,分隔符 可以是,、/、-、\(注意转义)、|、; 作为分隔符。
|
public static boolean isEmptyString(String str)
str - 要判断的字符串public static String[] split(String str)
str - 输入的字符串public static String repeatStr(String str, String div, int repeat)
str - 要重复的字符串div - 字符串之间的分隔符repeat - 重复次数public static boolean containsIgnoreCase(String a, String b)
a - 输入字符串 ab - 另一个字符串 bpublic static String regMatch(String regexp, String str)
regexp - 正则str - 测试的字符串public static String regMatch(String regexp, String str, int groupIndex)
regexp - 正则str - 测试的字符串groupIndex - 分组 id,若为 -1 则取最后一个分组public static String[] regMatchAll(String regexp, String str)
regexp - 正则str - 测试的字符串public static boolean isNull(Object[] arr)
arr - 输入的数组public static boolean isNull(Collection<?> collection)
collection - Map输入的集合public static boolean isNull(Map<?,?> map)
map - 输入的public static String formatDate(Date date)
date - 输入的时间public static String formatDateShorter(Date date)
date - 输入的时间public static String now()
public static Date Objet2Date(Object obj)
obj - 任意对象public static SimpleDateFormat simpleDateFormatFactory(String format)
new SimpleDateFormat(format).format(System.currentTimeMillis());
返回 SimpleDateFormat 的工厂函数format - 日期格式public static String getRandomString(int length)
length - 户要求产生字符串的长度Copyright © 2013–2021 AJAXJS. All rights reserved.