Class DateUtil

java.lang.Object
org.rapidcontext.util.DateUtil

public final class DateUtil extends Object
A set of utility methods for handling date and time objects.
Version:
1.0
  • Method Details

    • isEpochFormat

      public static boolean isEpochFormat(String str)
      Checks if a string is in Unix epoch format. Note that there is no safe way to distinguish between epoch values in second vs. millisecond resolution for all cases.
      Parameters:
      str - the string to test
      Returns:
      true if the string is in epoch format, or false otherwise
    • asEpochMillis

      public static String asEpochMillis(Date date)
      Formats a date and time in Unix (millisecond) epoch format (i.e. "@1653037430316").
      Parameters:
      date - the date and time to convert
      Returns:
      the epoch millisecond string
    • asDateTimeUTC

      public static String asDateTimeUTC(Date date)
      Formats a date and time in an ISO 8601 datetime representation for the UTC timezone.
      Parameters:
      date - the date and time to convert
      Returns:
      the ISO 8601 datetime string in UTC
    • formatIsoDateTime

      public static String formatIsoDateTime(Date date)
      Formats a date and time to an ISO datetime representation (without timezone).
      Parameters:
      date - the date and time to convert
      Returns:
      the ISO datetime string
    • formatIsoTime

      public static String formatIsoTime(Date date)
      Formats a time to an ISO time representation (without timezone).
      Parameters:
      date - the date and time to convert
      Returns:
      the ISO time string