public interface DurationFormatter
| Modifier and Type | Method and Description |
|---|---|
String |
formatDurationFrom(long duration,
long referenceDate)
Formats a duration expressed in milliseconds from a reference date.
|
String |
formatDurationFromNow(long duration)
Formats a duration expressed in milliseconds.
|
String |
formatDurationFromNowTo(Date targetDate)
Formats the duration between now and a target date.
|
DurationFormatter |
withLocale(String localeName)
Returns a new DurationFormatter that's the same as this one
but formats for a new locale.
|
DurationFormatter |
withTimeZone(TimeZone tz)
Returns a new DurationFormatter that's the same as this one but
uses a different time zone.
|
String formatDurationFromNowTo(Date targetDate)
This is a convenience method that calls
formatDurationFrom(long, long) using now
as the reference date, and the difference between now and
targetDate.getTime() as the duration.
targetDate - the ending dateString formatDurationFromNow(long duration)
This is a convenience method that calls formatDurationFrom using the current system time as the reference date.
duration - the duration in millisecondstz - the time zoneString formatDurationFrom(long duration, long referenceDate)
The reference date allows formatters to use actual durations of variable-length periods (like months) if they wish.
The duration is expressed as the number of milliseconds in the past (negative values) or future (positive values) with respect to a reference date (expressed as milliseconds in epoch).
duration - the duration in millisecondsreferenceDate - the date from which to compute the durationDurationFormatter withLocale(String localeName)
localeName - the name of the new localeDurationFormatter withTimeZone(TimeZone tz)
tz - the time zone in which to compute durations.