Class TimeFormatKit

java.lang.Object
com.iohao.net.common.kit.time.TimeFormatKit

public final class TimeFormatKit extends Object
Date/time formatting utilities with cached DateTimeFormatter instances.
Since:
21.16
Author:
渔民小镇
date:
2024-08-27
  • Method Details

    • ofPattern

      public static DateTimeFormatter ofPattern(String pattern)
      get singleton DateTimeFormatter by pattern
      Parameters:
      pattern - the pattern to use, not null
      Returns:
      the formatter based on the pattern, not null
    • format

      public static String format()
      Format the current date/time as yyyy-MM-dd HH:mm:ss.
      Returns:
      the formatted current date/time string
    • format

      public static String format(long timeMillis)
      Format the given epoch milliseconds as yyyy-MM-dd HH:mm:ss.
      Parameters:
      timeMillis - the epoch milliseconds to format
      Returns:
      the formatted date/time string
    • format

      public static String format(TemporalAccessor temporal)
      Format the given temporal as yyyy-MM-dd HH:mm:ss.
      Parameters:
      temporal - the temporal to format
      Returns:
      the formatted date/time string
    • format

      public static String format(TemporalAccessor temporal, String pattern)
      Format the given temporal using the specified pattern.
      Parameters:
      temporal - the temporal to format
      pattern - the date/time pattern to use
      Returns:
      the formatted date/time string