Package com.avoka.core.util
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 TimeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateparseIso8601Date(String value)Parse a ISO 8601 Date string and return a Java Date.static DateparseJsonDateTime(String value)Parse a JSON ISO DateTime string without milliseconds and return a Java Date, or null otherwise.static DateparseSimpleDateTime(String value)Parse a date string and return a Java Date.static StringtoDisplayTime(long timeSeconds, boolean shortFormat)Return a time display formatted string for the given seconds time duration.static StringtoDisplayTime(long timeSeconds, boolean shortFormat, boolean includeSeconds)Return a time display formatted string for the given seconds time duration.static StringtoDisplayTimeFromMs(long timeMilliseconds)Return a time display short formatted string for the given milliseconds time duration.static StringtoJsonDateTime(Date date)Return a JSON ISO DateTime string without milliseconds if the date is not null, or null otherwise.
-
-
-
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 secondsshortFormat- 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 secondsshortFormat- use short formatincludeSeconds- 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
-
-