类 DateSupport

java.lang.Object
gu.sql2java.utils.DateSupport

public class DateSupport extends Object
日期工具类
从以下版本开始:
3.29.2
作者:
guyadong
  • 字段详细资料

    • TIMESTAMP_FORMATTER_STR

      public static final String TIMESTAMP_FORMATTER_STR
      用于SQL语句的时间戳格式转换格式
  • 构造器详细资料

    • DateSupport

      public DateSupport()
  • 方法详细资料

    • getDateFromString

      public static Date getDateFromString(String strDate, AtomicReference<String> pattern, int... excludeIndexs)
      get a date from a date string representation in one of the registered formats
      参数:
      strDate - the date as string.
      pattern - [out] if not null, return pattern string or null if (null or empty) or correct pattern was not found
      excludeIndexs - excluded pattern index
      返回:
      Date object ,otherwise null If (null or empty) or correct pattern was not found
    • getDateFromString

      public static Date getDateFromString(String strDate)
      get a date from a date string representation in one of the registered formats
      参数:
      strDate - the date as string.
      返回:
      Date object ,otherwise null If (null or empty) or correct pattern was not found
    • parseDateString

      public static <D extends Date> D parseDateString(String dateStr, Class<D> targetClass)
      get a date from a date string representation in one of the registered formats
      参数:
      dateStr - the date as string.
      targetClass -
      返回:
      Date object ,otherwise null If (null or empty) or correct pattern was not found
    • parseAsDate

      public static <D> D parseAsDate(String input, Class<D> targetClass, int... excludeIndexs)
      get a date from a date string representation in one of the registered formats
      参数:
      input - the date as string.
      targetClass - Date or Calendar or subclass required
      excludeIndexs - excluded pattern index
      返回:
      Date object ,otherwise null If (null or empty) or correct pattern was not found
    • toISO8601String

      public static String toISO8601String(Date date)
      convert Date to ISO8601 date time format string
      参数:
      date -
      返回:
      ISO8601 date time format string or null if date is null
    • formatDate

      public static String formatDate(Date date, String format)
      format Date to string
      参数:
      date -
      format - date time format string,use ISO8601 format if null
      返回:
      ISO8601 date time format string or null if date is null
    • isDate

      public static boolean isDate(String strDate)
      Verify that the string represantes the date with one of the registered formats
      参数:
      strDate - the date as string.
      返回:
      boolean "true" if the string represantes the date in one of the registed formats.
    • patternOf

      public static String patternOf(String strDate)
      Verify that the string represantes the date with one of the registered formats
      参数:
      strDate - the date as string.
      返回:
      boolean "true" if the string represantes the date in one of the registed formats.
      从以下版本开始:
      3.25.0
    • castToDate

      public static <F, T> T castToDate(F from, Class<T> targetClass)
      将对象转为指定的日期类型
      类型参数:
      F - 原类型 String,Number,java.util.Date or Calendar or subclass
      T - 目标类型 java.util.Date or Calendar or subclass
      参数:
      from -
      targetClass -