Class TirsciUtil

java.lang.Object
cn.sinozg.applet.common.utils.TirsciUtil

public class TirsciUtil extends Object
工具类 自己用
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • RANDOM

      private static final SecureRandom RANDOM
  • Constructor Details

    • TirsciUtil

      private TirsciUtil()
  • Method Details

    • tryCatch

      public static <T> T tryCatch(SupplierException<T> supplier)
      异常捕获起来
      Type Parameters:
      T - 类型
      Parameters:
      supplier - 要执行的方法
      Returns:
      返回数据
    • format

      public static String format(String strPattern, Object... argArray)

      格式化文本, {} 表示占位符

      此方法只是简单将占位符 {} 按照顺序替换为参数

      如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可

      例:

       
        // 通常使用 -> 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

      public static String utcPattern(DatePattern pattern, Supplier<Map<String,Object>> supplier)
      获取到用户的时区格式
      Parameters:
      pattern - 时区格式
      supplier - other 函数
      Returns:
      时区格式