Top Description Fields Constructors Methods
com.ibm.icu.text

public abstract Class DurationFormat

extends UFormat
Class Inheritance
Known Direct Subclasses
com.ibm.icu.impl.duration.BasicDurationFormat
Annotations
@Deprecated
Imports
java.text.FieldPosition, .ParsePosition, java.util.Date, com.ibm.icu.impl.duration.BasicDurationFormat, com.ibm.icu.util.ULocale

Deprecated

ICU 56 Use MeasureFormat or RelativeDateTimeFormatter instead.

This deprecated class implements a formatter over a duration in time such as "2 days from now" or "3 hours ago".

Use MeasureFormat to format periods like "5 days, 3 hours"; use RelativeDateTimeFormatter to format relative dates like "5 days ago".

See Also
MeasureFormat, RelativeDateTimeFormatter

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
DurationFormat()

Deprecated This API is ICU internal only.
Subclass interface
protected
DurationFormat(ULocale locale)

Deprecated This API is ICU internal only.
Subclass interface

Method Summary

Modifier and TypeMethod and Description
public abstract StringBuffer

Returns:

the toAppend buffer
format
(Object
the object to format. Should be either a Long, Date, or javax.xml.datatype.Duration object.
object
,
StringBuffer
the buffer to append to
toAppend
,
FieldPosition
the field position, may contain additional error messages.
pos
)

Implements abstract java.text.Format.format.

Deprecated ICU 56
Format an arbitrary object.
public abstract String

Returns:

the formatted time
formatDurationFrom
(long
the duration in milliseconds
duration
,
long
the date from which to compute the duration
referenceDate
)

Deprecated ICU 56
Formats a duration expressed in milliseconds from a reference date.
public abstract String

Returns:

the formatted time
formatDurationFromNow
(long
the duration in milliseconds
duration
)

Deprecated ICU 56
Formats a duration expressed in milliseconds.
public abstract String

Returns:

the formatted time
formatDurationFromNowTo
(Date
the ending date
targetDate
)

Deprecated ICU 56
Formats the duration between now and a target date.
public static DurationFormat
getInstance(ULocale locale)

Deprecated ICU 56
Construct a duration format for the specified locale
public Object
parseObject(String
A String, part of which should be parsed.
source
,
ParsePosition
A ParsePosition object with index and error index information as described above.
pos
)

Implements abstract java.text.Format.parseObject.

Deprecated ICU 56
DurationFormat cannot parse, by default.
Inherited from com.ibm.icu.text.UFormat:
getLocalesetLocale

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.ibm.icu.text.UFormat.serialVersionUID.

Constructor Detail

DurationFormatback to summary
protected DurationFormat()

Deprecated

This API is ICU internal only.

Subclass interface

Annotations
@Deprecated
ICU Status
Internal ICU component.
DurationFormatback to summary
protected DurationFormat(ULocale locale)

Deprecated

This API is ICU internal only.

Subclass interface

Annotations
@Deprecated
ICU Status
Internal ICU component.

Method Detail

formatback to summary
public abstract StringBuffer format(Object object, StringBuffer toAppend, FieldPosition pos)

Implements abstract java.text.Format.format.

Deprecated

ICU 56

Format an arbitrary object. Defaults to a call to formatDurationFromNow() for either Long or Date objects.

Parameters
object:Object

the object to format. Should be either a Long, Date, or javax.xml.datatype.Duration object.

toAppend:StringBuffer

the buffer to append to

pos:FieldPosition

the field position, may contain additional error messages.

Returns:StringBuffer

the toAppend buffer

Annotations
@Deprecated
@Override
formatDurationFromback to summary
public abstract String formatDurationFrom(long duration, long referenceDate)

Deprecated

ICU 56

Formats a duration expressed in milliseconds from a reference date.

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).

Parameters
duration:long

the duration in milliseconds

referenceDate:long

the date from which to compute the duration

Returns:String

the formatted time

Annotations
@Deprecated
formatDurationFromNowback to summary
public abstract String formatDurationFromNow(long duration)

Deprecated

ICU 56

Formats a duration expressed in milliseconds.

This is a convenience method that calls formatDurationFrom using the current system time as the reference date.

Parameters
duration:long

the duration in milliseconds

Returns:String

the formatted time

Annotations
@Deprecated
formatDurationFromNowToback to summary
public abstract String formatDurationFromNowTo(Date targetDate)

Deprecated

ICU 56

Formats the duration between now and a target date.

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.

Parameters
targetDate:Date

the ending date

Returns:String

the formatted time

Annotations
@Deprecated
getInstanceback to summary
public static DurationFormat getInstance(ULocale locale)

Deprecated

ICU 56

Construct a duration format for the specified locale

Annotations
@Deprecated
parseObjectback to summary
public Object parseObject(String source, ParsePosition pos)

Implements abstract java.text.Format.parseObject.

Deprecated

ICU 56

DurationFormat cannot parse, by default. This method will throw an UnsupportedOperationException.

Parameters
source:String

Doc from java.text.Format.parseObject.

A String, part of which should be parsed.

pos:ParsePosition

Doc from java.text.Format.parseObject.

A ParsePosition object with index and error index information as described above.

Returns:Object

Doc from java.text.Format.parseObject.

An Object parsed from the string. In case of error, returns null.

Annotations
@Override
@Deprecated