public class DateParser
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static long |
ONE_DAY |
static long |
ONE_HOUR |
static long |
ONE_MINUTE |
static long |
ONE_SECOND |
| Constructor and Description |
|---|
DateParser() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
computeTimeAgoString(long ts,
java.lang.String suffix)
Takes the time in milliseconds since the epoch and
converts it into a string of "x days/hours/minutes/seconds"
compared to the current time.
|
static java.util.Date |
parseURLDate(java.lang.String dateStr,
java.util.Date defaultDate) |
static java.lang.String |
timeToReadable(long millis)
Format the given number of milliseconds as readable string.
|
static java.lang.String |
timeToReadable(long millis,
java.lang.String suffix)
Format the given number of milliseconds as readable string, optionally
appending a suffix.
|
public static final long ONE_SECOND
public static final long ONE_MINUTE
public static final long ONE_HOUR
public static final long ONE_DAY
public static java.util.Date parseURLDate(java.lang.String dateStr,
java.util.Date defaultDate)
public static java.lang.String computeTimeAgoString(long ts,
java.lang.String suffix)
ts - The timestamp in milliseconds since the epochsuffix - Some text that is appended only if there is a time-difference, i.e.
it is not appended when the time is now.public static java.lang.String timeToReadable(long millis)
millis - The number of milliseconds to print.public static java.lang.String timeToReadable(long millis,
java.lang.String suffix)
millis - The number of milliseconds to print.suffix - A suffix that is appended if the millis is > 0, specify "" if not needed.