Package com.ibm.icu.text
Class DurationFormat
- java.lang.Object
-
- java.text.Format
-
- com.ibm.icu.text.UFormat
-
- com.ibm.icu.text.DurationFormat
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
@Deprecated public abstract class DurationFormat extends UFormat
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
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.text.UFormat
UFormat.SpanField
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DurationFormat()
Deprecated.This API is ICU internal only.protected
DurationFormat(ULocale locale)
Deprecated.This API is ICU internal only.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.StringBuffer
format(java.lang.Object object, java.lang.StringBuffer toAppend, java.text.FieldPosition pos)
Deprecated.ICU 56abstract java.lang.String
formatDurationFrom(long duration, long referenceDate)
Deprecated.ICU 56abstract java.lang.String
formatDurationFromNow(long duration)
Deprecated.ICU 56abstract java.lang.String
formatDurationFromNowTo(java.util.Date targetDate)
Deprecated.ICU 56static DurationFormat
getInstance(ULocale locale)
Deprecated.ICU 56java.lang.Object
parseObject(java.lang.String source, java.text.ParsePosition pos)
Deprecated.ICU 56
-
-
-
Constructor Detail
-
DurationFormat
@Deprecated protected DurationFormat()
Deprecated.This API is ICU internal only.Subclass interface
-
DurationFormat
@Deprecated protected DurationFormat(ULocale locale)
Deprecated.This API is ICU internal only.Subclass interface
-
-
Method Detail
-
getInstance
@Deprecated public static DurationFormat getInstance(ULocale locale)
Deprecated.ICU 56Construct a duration format for the specified locale
-
format
@Deprecated public abstract java.lang.StringBuffer format(java.lang.Object object, java.lang.StringBuffer toAppend, java.text.FieldPosition pos)
Deprecated.ICU 56Format an arbitrary object. Defaults to a call to formatDurationFromNow() for either Long or Date objects.- Specified by:
format
in classjava.text.Format
- Parameters:
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.- Returns:
- the toAppend buffer
-
parseObject
@Deprecated public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)
Deprecated.ICU 56DurationFormat cannot parse, by default. This method will throw an UnsupportedOperationException.- Specified by:
parseObject
in classjava.text.Format
-
formatDurationFromNowTo
@Deprecated public abstract java.lang.String formatDurationFromNowTo(java.util.Date targetDate)
Deprecated.ICU 56Formats 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
- the ending date- Returns:
- the formatted time
-
formatDurationFromNow
@Deprecated public abstract java.lang.String formatDurationFromNow(long duration)
Deprecated.ICU 56Formats a duration expressed in milliseconds.This is a convenience method that calls formatDurationFrom using the current system time as the reference date.
- Parameters:
duration
- the duration in milliseconds- Returns:
- the formatted time
-
formatDurationFrom
@Deprecated public abstract java.lang.String formatDurationFrom(long duration, long referenceDate)
Deprecated.ICU 56Formats 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
- the duration in millisecondsreferenceDate
- the date from which to compute the duration- Returns:
- the formatted time
-
-