Package com.avoka.core.util
Class TimeUtils
java.lang.Object
com.avoka.core.util.TimeUtils
Provides a time utility class.
- Since:
- 4.0.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Date
checkForDayLightSavings
(Date date) Check for Daylight saving in a particular timezone and return the updated datestatic Date
parseIso8601Date
(String value) Parse a ISO 8601 Date string and return a Java Date.static Date
parseJsonDateTime
(String value) Parse a JSON ISO DateTime string without milliseconds and return a Java Date, or null otherwise.static Date
parseSimpleDateTime
(String value) Parse a date string and return a Java Date.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 stringstatic 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
toJsonDateTime
(Date date) Return a JSON ISO DateTime string without milliseconds if the date is not null, or null otherwise.
-
Constructor Details
-
TimeUtils
public TimeUtils()
-
-
Method Details
-
toDisplayTimeFromMs
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
Return a time display formatted string for the given seconds time duration.- Parameters:
timeSeconds
- the time duration in secondsshortFormat
- use short format- Returns:
- a time display formatted string for the given seconds time duration.
-
toDisplayTime
Return a time display formatted string for the given seconds time duration.- Parameters:
timeSeconds
- the time duration in secondsshortFormat
- use short formatincludeSeconds
- include seconds component- Returns:
- a time display formatted string for the given seconds time duration.
-
toJsonDateTime
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
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
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
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
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
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
-