Package ch.autumo.commons.utils.common
Class Time
java.lang.Object
ch.autumo.commons.utils.common.Time
Time utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetGUIDate(Timestamp tsFromDb) Get a timestamp representation that can be shown in GUIstatic StringgetReadableDuration(long durationInMilliseconds, TimeUnit printUpTo) Get readable duration.static StringGet a time-stamp representation that can be stored in DB.static StringGet a time-stamp representation that can be stored in DB.
-
Method Details
-
getReadableDuration
Get readable duration.- Parameters:
durationInMilliseconds- duration in msprintUpTo- The maximum timeunit that should be printed- Returns:
- readable duration
-
getGUIDate
Get a timestamp representation that can be shown in GUI- Parameters:
tsFromDb- from DB- Returns:
- timestamp representable date
-
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
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
-