Class Time

java.lang.Object
ch.autumo.commons.utils.common.Time

public class Time extends Object
Time utilities.
  • Method Details

    • getReadableDuration

      public static String getReadableDuration(long durationInMilliseconds, TimeUnit printUpTo)
      Get readable duration.
      Parameters:
      durationInMilliseconds - duration in ms
      printUpTo - The maximum timeunit that should be printed
      Returns:
      readable duration
    • getGUIDate

      public static String getGUIDate(Timestamp tsFromDb)
      Get a timestamp representation that can be shown in GUI
      Parameters:
      tsFromDb - from DB
      Returns:
      timestamp representable date
    • nowTimeStamp

      public static String nowTimeStamp()
      Get a time-stamp representation that can be stored in DB. Note that this code returns a 'to_timestamp'-call when you are using an Oracle database, hence that value cannot be enclosed with apostrophes '...'; in case of Oracle it looks like this: "to_timestamp('2022-12-21 23:59:59.999', 'YYYY-MM-DD HH24:MI:SS.FF')" and in case of all other databases: "2022-12-21 23:59:59.999"
      Returns:
      time-stamp a time-stamp representation that works with used DB
    • timeStamp

      public static String timeStamp(Date date)
      Get a time-stamp representation that can be stored in DB. Note that this code returns a 'to_timestamp'-call when you are using an Oracle database, hence that value cannot be enclosed with apostrophes '...'; in case of Oracle it looks like this: "to_timestamp('2022-12-21 23:59:59.999', 'YYYY-MM-DD HH24:MI:SS.FF')" and in case of all other databases: "2022-12-21 23:59:59.999"
      Parameters:
      date - create time-stamp out of given date
      Returns:
      time-stamp a time-stamp representation that works with used DB