public class Durations extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
MS_DAY |
static long |
MS_HOUR |
static long |
MS_MILLISECOND |
static long |
MS_MINUTE |
static long |
MS_SECOND |
static long |
MS_WEEK |
| Constructor and Description |
|---|
Durations() |
| Modifier and Type | Method and Description |
|---|---|
static Long |
dehumanize(String time)
Converts a human readable duration in the format "Xd Xh Xm Xs Xms" to miliseconds.
|
static String |
fromDuration(Duration duration)
Converts a time from java.util.time.Duration to human readable format "Xd Xh Xm Xs Xms" (for interoperability).
|
static String |
humanize(long time)
Converts a time in miliseconds to human readable duration in the format "Xd Xh Xm Xs Xms"
|
static String |
humanize(long time,
String separator) |
static String |
timeAgo(Date date)
Prints how long the given date is ago in the format "Xd Xh Xm Xs Xms"
|
static String |
timeAgo(Instant date)
Prints how long the given date is ago in the format "Xd Xh Xm Xs Xms"
|
protected static String |
timeAgo(Instant date,
Instant reference) |
static String |
timeLeft(Date date)
Prints how long the given date is in the future in the format "Xd Xh Xm Xs Xms"
|
static String |
timeLeft(Instant date)
Prints how long the given date is in the future in the format "Xd Xh Xm Xs Xms"
|
static Duration |
toDuration(String time)
Converts a time in human readable format "Xd Xh Xm Xs Xms" to java.util.time.Duration (for interoperability).
|
public static final long MS_MILLISECOND
public static final long MS_SECOND
public static final long MS_MINUTE
public static final long MS_HOUR
public static final long MS_DAY
public static final long MS_WEEK
public static String timeLeft(Date date)
public static String timeLeft(Instant date)
public static String timeAgo(Date date)
public static String timeAgo(Instant date)
public static String humanize(long time)
public static Long dehumanize(String time)
public static Duration toDuration(String time)
Copyright © 2017. All rights reserved.