Class TimeUtils

java.lang.Object
com.avoka.core.util.TimeUtils

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Date
    Check for Daylight saving in a particular timezone and return the updated date
    static Date
    Parse a ISO 8601 Date string and return a Java Date.
    static Date
    Parse a JSON ISO DateTime string without milliseconds and return a Java Date, or null otherwise.
    static Date
    Parse a date string and return a Java Date.
    static Date
    Converts a string to a Date If the string starts with yyyy-mm-dd is will be parsed as an ISO 8601 format If the string has the format of yyyy-mm-dd HH:MM:SS it will be parsed as a simple datetime Else it will be parsed as a standard date string
    static String
    toDisplayTime(long timeSeconds, boolean shortFormat)
    Return a time display formatted string for the given seconds time duration.
    static String
    toDisplayTime(long timeSeconds, boolean shortFormat, boolean includeSeconds)
    Return a time display formatted string for the given seconds time duration.
    static String
    toDisplayTimeFromMs(long timeMilliseconds)
    Return a time display short formatted string for the given milliseconds time duration.
    static String
    Return a JSON ISO DateTime string without milliseconds if the date is not null, or null otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimeUtils

      public TimeUtils()
  • Method Details

    • 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
    • checkForDayLightSavings

      public static Date checkForDayLightSavings(Date date)
      Check for Daylight saving in a particular timezone and return the updated date
      Parameters:
      date - the date to be updated
      Returns:
      the updated date object
      Since:
      22.4.0
    • parseStringToDateTime

      public static Date parseStringToDateTime(String dateString)
      Converts a string to a Date If the string starts with yyyy-mm-dd is will be parsed as an ISO 8601 format If the string has the format of yyyy-mm-dd HH:MM:SS it will be parsed as a simple datetime Else it will be parsed as a standard date string
      Parameters:
      dateString - to parse
      Returns:
      date object of parsed string
      Since:
      22.10.0