Class TimeUtils


  • public class TimeUtils
    extends Object
    Provides a time utility class.
    Since:
    4.0.0
    • Constructor Detail

      • TimeUtils

        public TimeUtils()
    • Method Detail

      • toDisplayTimeFromMs

        public static String toDisplayTimeFromMs​(long timeMilliseconds)
        Return a time display short formatted string for the given milliseconds time duration.
        Parameters:
        timeMilliseconds - the time duration in milliseconds
        Returns:
        a time display formatted string for the given milliseconds time duration.
        Since:
        4.3.4
      • toDisplayTime

        public static String toDisplayTime​(long timeSeconds,
                                           boolean shortFormat)
        Return a time display formatted string for the given seconds time duration.
        Parameters:
        timeSeconds - the time duration in seconds
        shortFormat - use short format
        Returns:
        a time display formatted string for the given seconds time duration.
      • toDisplayTime

        public static String toDisplayTime​(long timeSeconds,
                                           boolean shortFormat,
                                           boolean includeSeconds)
        Return a time display formatted string for the given seconds time duration.
        Parameters:
        timeSeconds - the time duration in seconds
        shortFormat - use short format
        includeSeconds - include seconds component
        Returns:
        a time display formatted string for the given seconds time duration.
      • toJsonDateTime

        public static String toJsonDateTime​(Date date)
        Return a JSON ISO DateTime string without milliseconds if the date is not null, or null otherwise.
        Parameters:
        date - the date to format (optional)
        Returns:
        a JSON ISO DateTime string without milliseconds if the date is not null, or null otherwise
        Since:
        4.3.0
      • parseJsonDateTime

        public static Date parseJsonDateTime​(String value)
        Parse a JSON ISO DateTime string without milliseconds and return a Java Date, or null otherwise.
        Parameters:
        value - a JSON ISO DateTime string without milliseconds
        Returns:
        a Java Date value, or null otherwise
        Since:
        4.3.0
      • parseIso8601Date

        public static Date parseIso8601Date​(String value)
        Parse a ISO 8601 Date string and return a Java Date.
        Parameters:
        value - a ISO 8601 Date string
        Returns:
        a Java Date value, or null if value was blank
        Since:
        18.11.0
      • parseSimpleDateTime

        public static Date parseSimpleDateTime​(String value)
        Parse a date string and return a Java Date.
        Parameters:
        value - a date string in the format yyyy-MM-dd kk:mm:ss
        Returns:
        a Java Date value, or null if value was blank
        Since:
        18.11.0