public class BasicDurationFormat extends DurationFormat
UFormat.SpanFieldFormat.Field| Constructor and Description |
|---|
BasicDurationFormat() |
BasicDurationFormat(ULocale locale) |
| Modifier and Type | Method and Description |
|---|---|
StringBuffer |
format(Object object,
StringBuffer toAppend,
FieldPosition pos)
Format an arbitrary object.
|
String |
formatDuration(Object obj)
JDK 1.5+ only
|
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.
|
static BasicDurationFormat |
getInstance(ULocale locale) |
clone, format, formatToCharacterIterator, parseObject, parseObjectpublic BasicDurationFormat()
public BasicDurationFormat(ULocale locale)
public static BasicDurationFormat getInstance(ULocale locale)
public StringBuffer format(Object object, StringBuffer toAppend, FieldPosition pos)
DurationFormatformat in class DurationFormatobject - the object to format. Should be either a Long, Date, or javax.xml.datatype.Duration object.toAppend - the buffer to append topos - the field position, may contain additional error messages.public String formatDurationFrom(long duration, long referenceDate)
DurationFormatThe 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).
formatDurationFrom in class DurationFormatduration - the duration in millisecondsreferenceDate - the date from which to compute the durationpublic String formatDurationFromNow(long duration)
DurationFormatThis is a convenience method that calls formatDurationFrom using the current system time as the reference date.
formatDurationFromNow in class DurationFormatduration - the duration in millisecondspublic String formatDurationFromNowTo(Date targetDate)
DurationFormat
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.
formatDurationFromNowTo in class DurationFormattargetDate - the ending date