|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
com.ibm.icu.text.UFormat
com.ibm.icu.text.DurationFormat
public abstract class DurationFormat
This class implements a formatter over a duration in time such as "2 days from now" or "3 hours ago".
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.text.Format |
---|
Format.Field |
Constructor Summary | |
---|---|
protected |
DurationFormat()
Deprecated. This API is ICU internal only. |
protected |
DurationFormat(ULocale locale)
Deprecated. This API is ICU internal only. |
Method Summary | |
---|---|
abstract StringBuffer |
format(Object object,
StringBuffer toAppend,
FieldPosition pos)
Format an arbitrary object. |
abstract String |
formatDurationFrom(long duration,
long referenceDate)
Formats a duration expressed in milliseconds from a reference date. |
abstract String |
formatDurationFromNow(long duration)
Formats a duration expressed in milliseconds. |
abstract String |
formatDurationFromNowTo(Date targetDate)
Formats the duration between now and a target date. |
static DurationFormat |
getInstance(ULocale locale)
Construct a duration format for the specified locale |
Object |
parseObject(String source,
ParsePosition pos)
DurationFormat cannot parse, by default. |
Methods inherited from class com.ibm.icu.text.UFormat |
---|
getLocale |
Methods inherited from class java.text.Format |
---|
clone, format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DurationFormat()
protected DurationFormat(ULocale locale)
Method Detail |
---|
public static DurationFormat getInstance(ULocale locale)
public abstract StringBuffer format(Object object, StringBuffer toAppend, FieldPosition pos)
format
in class Format
object
- 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 Object parseObject(String source, ParsePosition pos)
parseObject
in class Format
public abstract 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 date
public abstract String formatDurationFromNow(long duration)
This is a convenience method that calls formatDurationFrom using the current system time as the reference date.
duration
- the duration in milliseconds
public abstract String 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 duration
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |