Package de.galan.commons.time
Class Durations
java.lang.Object
de.galan.commons.time.Durations
Utility class to handle human readable time durations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Longdehumanize(String time) Converts a human readable duration in the format "Xd Xh Xm Xs Xms" to miliseconds.static StringfromDuration(Duration duration) Converts a time from java.util.time.Duration to human readable format "Xd Xh Xm Xs Xms" (for interoperability).static Stringhumanize(long time) Converts a time in miliseconds to human readable duration in the format "XdXhXmXsXms"static StringConverts a time in miliseconds to human readable duration in the format "Xd Xh Xm Xs Xms" (example when the separator is a SPACE).static Stringstatic Stringstatic StringPrints how long the given date is ago in the format "Xd Xh Xm Xs Xms"protected static Stringstatic StringPrints how long the given date is ago in the format "Xd Xh Xm Xs Xms"static StringPrints how long the given date is in the future in the format "Xd Xh Xm Xs Xms"static StringPrints how long the given date is in the future in the format "Xd Xh Xm Xs Xms"static DurationtoDuration(String time) Converts a time in human readable format "Xd Xh Xm Xs Xms" to java.util.time.Duration (for interoperability).
-
Field Details
-
MS_MILLISECOND
public static final long MS_MILLISECOND- See Also:
-
MS_SECOND
public static final long MS_SECOND- See Also:
-
MS_MINUTE
public static final long MS_MINUTE- See Also:
-
MS_HOUR
public static final long MS_HOUR- See Also:
-
MS_DAY
public static final long MS_DAY- See Also:
-
MS_WEEK
public static final long MS_WEEK- See Also:
-
-
Constructor Details
-
Durations
public Durations()
-
-
Method Details
-
timeLeft
Prints how long the given date is in the future in the format "Xd Xh Xm Xs Xms" -
timeLeft
Prints how long the given date is in the future in the format "Xd Xh Xm Xs Xms" -
timeAgo
Prints how long the given date is ago in the format "Xd Xh Xm Xs Xms" -
timeAgo
Prints how long the given date is ago in the format "Xd Xh Xm Xs Xms" -
timeAgo
-
humanize
Converts a time in miliseconds to human readable duration in the format "XdXhXmXsXms" -
humanize
-
humanize
-
humanize
Converts a time in miliseconds to human readable duration in the format "Xd Xh Xm Xs Xms" (example when the separator is a SPACE). -
dehumanize
Converts a human readable duration in the format "Xd Xh Xm Xs Xms" to miliseconds. -
toDuration
Converts a time in human readable format "Xd Xh Xm Xs Xms" to java.util.time.Duration (for interoperability). -
fromDuration
Converts a time from java.util.time.Duration to human readable format "Xd Xh Xm Xs Xms" (for interoperability).
-