Package cn.sinozg.applet.common.utils
Class TirsciUtil
java.lang.Object
cn.sinozg.applet.common.utils.TirsciUtil
工具类 自己用
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate static final SecureRandom -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String格式化文本, {} 表示占位符static booleanisTimeField(com.fasterxml.jackson.databind.BeanProperty property) 判断是否为 日期static intnextInt(int bound) 随机整数 [0,bound)static <T> TtryCatch(SupplierException<T> supplier) 异常捕获起来static StringutcPattern(DatePattern pattern, Supplier<Map<String, Object>> supplier) 获取到用户的时区格式
-
Field Details
-
log
private static final org.slf4j.Logger log -
RANDOM
-
-
Constructor Details
-
TirsciUtil
private TirsciUtil()
-
-
Method Details
-
tryCatch
异常捕获起来- Type Parameters:
T- 类型- Parameters:
supplier- 要执行的方法- Returns:
- 返回数据
-
format
格式化文本, {} 表示占位符
此方法只是简单将占位符 {} 按照顺序替换为参数
如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
例:
// 通常使用 -> this is a for b format("this is {} for {}", "a", "b") // 转义{}:-> this is \{} for a format("this is \\{} for {}", "a", "b") // 转义\::-> this is \a for b format("this is \\\\{} for {}", "a", "b")- Parameters:
strPattern- 文本模板,被替换的部分用 {} 表示argArray- 参数值- Returns:
- 格式化后的文本
-
nextInt
public static int nextInt(int bound) 随机整数 [0,bound)- Parameters:
bound- 最大- Returns:
- 整数
-
isTimeField
public static boolean isTimeField(com.fasterxml.jackson.databind.BeanProperty property) 判断是否为 日期- Parameters:
property- property- Returns:
- 是否为日期
-
utcPattern
获取到用户的时区格式- Parameters:
pattern- 时区格式supplier- other 函数- Returns:
- 时区格式
-