Package com.ibm.icu.impl.duration
Class BasicDurationFormat
- java.lang.Object
-
- java.text.Format
-
- com.ibm.icu.text.UFormat
-
- com.ibm.icu.text.DurationFormat
-
- com.ibm.icu.impl.duration.BasicDurationFormat
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class BasicDurationFormat extends DurationFormat
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.text.UFormat
UFormat.SpanField
-
-
Field Summary
Fields Modifier and Type Field Description (package private) DurationFormatter
formatter
(package private) PeriodFormatter
pformatter
(package private) PeriodFormatterService
pfs
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description BasicDurationFormat()
BasicDurationFormat(ULocale locale)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuffer
format(java.lang.Object object, java.lang.StringBuffer toAppend, java.text.FieldPosition pos)
Format an arbitrary object.java.lang.String
formatDuration(java.lang.Object obj)
JDK 1.5+ onlyjava.lang.String
formatDurationFrom(long duration, long referenceDate)
Formats a duration expressed in milliseconds from a reference date.java.lang.String
formatDurationFromNow(long duration)
Formats a duration expressed in milliseconds.java.lang.String
formatDurationFromNowTo(java.util.Date targetDate)
Formats the duration between now and a target date.static BasicDurationFormat
getInstance(ULocale locale)
-
Methods inherited from class com.ibm.icu.text.DurationFormat
parseObject
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
formatter
transient DurationFormatter formatter
-
pformatter
transient PeriodFormatter pformatter
-
pfs
transient PeriodFormatterService pfs
-
-
Constructor Detail
-
BasicDurationFormat
public BasicDurationFormat()
-
BasicDurationFormat
public BasicDurationFormat(ULocale locale)
-
-
Method Detail
-
getInstance
public static BasicDurationFormat getInstance(ULocale locale)
-
format
public java.lang.StringBuffer format(java.lang.Object object, java.lang.StringBuffer toAppend, java.text.FieldPosition pos)
Description copied from class:DurationFormat
Format an arbitrary object. Defaults to a call to formatDurationFromNow() for either Long or Date objects.- Specified by:
format
in classDurationFormat
- 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
-
formatDurationFrom
public java.lang.String formatDurationFrom(long duration, long referenceDate)
Description copied from class:DurationFormat
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).
- Specified by:
formatDurationFrom
in classDurationFormat
- Parameters:
duration
- the duration in millisecondsreferenceDate
- the date from which to compute the duration- Returns:
- the formatted time
-
formatDurationFromNow
public java.lang.String formatDurationFromNow(long duration)
Description copied from class:DurationFormat
Formats a duration expressed in milliseconds.This is a convenience method that calls formatDurationFrom using the current system time as the reference date.
- Specified by:
formatDurationFromNow
in classDurationFormat
- Parameters:
duration
- the duration in milliseconds- Returns:
- the formatted time
-
formatDurationFromNowTo
public java.lang.String formatDurationFromNowTo(java.util.Date targetDate)
Description copied from class:DurationFormat
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.- Specified by:
formatDurationFromNowTo
in classDurationFormat
- Parameters:
targetDate
- the ending date- Returns:
- the formatted time
-
formatDuration
public java.lang.String formatDuration(java.lang.Object obj)
JDK 1.5+ only- Parameters:
obj
- Object being passed.- Returns:
- The PeriodFormatter object formatted to the object passed.
- See Also:
- "http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/Duration.html"
-
-