Top Description Methods
com.ibm.icu.impl.duration

public Interface DurationFormatter

Known Direct Implementers
com.ibm.icu.impl.duration.BasicDurationFormatter
Imports
java.util.Date, .TimeZone

Formatter for durations in milliseconds.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

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

Formats a duration expressed in milliseconds from a reference date.

public String

Returns:

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

Formats a duration expressed in milliseconds.

public String

Returns:

the formatted time
formatDurationFromNowTo
(Date
the ending date
targetDate
)

Formats the duration between now and a target date.

public DurationFormatter

Returns:

a new formatter for the given locale
withLocale
(String
the name of the new locale
localeName
)

Returns a new DurationFormatter that's the same as this one but formats for a new locale.

public DurationFormatter

Returns:

a new formatter for the given locale
withTimeZone
(TimeZone
the time zone in which to compute durations.
tz
)

Returns a new DurationFormatter that's the same as this one but uses a different time zone.

Method Detail

formatDurationFromback to summary
public String formatDurationFrom(long duration, long referenceDate)

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

formatDurationFromNowback to summary
public String formatDurationFromNow(long duration)

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

formatDurationFromNowToback to summary
public String formatDurationFromNowTo(Date targetDate)

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

withLocaleback to summary
public DurationFormatter withLocale(String localeName)

Returns a new DurationFormatter that's the same as this one but formats for a new locale.

Parameters
localeName:String

the name of the new locale

Returns:DurationFormatter

a new formatter for the given locale

withTimeZoneback to summary
public DurationFormatter withTimeZone(TimeZone tz)

Returns a new DurationFormatter that's the same as this one but uses a different time zone.

Parameters
tz:TimeZone

the time zone in which to compute durations.

Returns:DurationFormatter

a new formatter for the given locale