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

pack-priv Class BasicDurationFormatter

extends Object
implements DurationFormatter
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.duration.DurationFormatter
Imports
java.util.Date, .TimeZone

Core implementation class for DurationFormatter.

Field Summary

Modifier and TypeField and Description
private PeriodBuilder
private DateFormatter
private long
private PeriodFormatter
private String
private TimeZone

Constructor Summary

AccessConstructor and Description
public
BasicDurationFormatter(PeriodFormatter formatter, PeriodBuilder builder, DateFormatter fallback, long fallbackLimit)

Creates a basic duration formatter with the given formatter, builder, and fallback.

protected
BasicDurationFormatter(PeriodFormatter formatter, PeriodBuilder builder, DateFormatter fallback, long fallbackLimit, String localeName, TimeZone timeZone)

Method Summary

Modifier and TypeMethod and Description
protected Period
doBuild(long duration, long referenceDate)

protected String
doFallback(long duration, long referenceDate)

protected String
doFormat(Period period)

public String
formatDurationFrom(long
the duration in milliseconds
duration
,
long
the date from which to compute the duration
referenceDate
)

Implements com.ibm.icu.impl.duration.DurationFormatter.formatDurationFrom.

Formats a duration expressed in milliseconds from a reference date.
public String
formatDurationFromNow(long
the duration in milliseconds
duration
)

Implements com.ibm.icu.impl.duration.DurationFormatter.formatDurationFromNow.

Formats a duration expressed in milliseconds.
public String
formatDurationFromNowTo(Date
the ending date
targetDate
)

Implements com.ibm.icu.impl.duration.DurationFormatter.formatDurationFromNowTo.

Formats the duration between now and a target date.
public DurationFormatter
withLocale(String
the name of the new locale
locName
)

Implements com.ibm.icu.impl.duration.DurationFormatter.withLocale.

Returns a new DurationFormatter that's the same as this one but formats for a new locale.
public DurationFormatter
withTimeZone(TimeZone
the time zone in which to compute durations.
tz
)

Implements com.ibm.icu.impl.duration.DurationFormatter.withTimeZone.

Returns a new DurationFormatter that's the same as this one but uses a different time zone.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

builderback to summary
private PeriodBuilder builder
fallbackback to summary
private DateFormatter fallback
fallbackLimitback to summary
private long fallbackLimit
formatterback to summary
private PeriodFormatter formatter
localeNameback to summary
private String localeName
timeZoneback to summary
private TimeZone timeZone

Constructor Detail

BasicDurationFormatterback to summary
public BasicDurationFormatter(PeriodFormatter formatter, PeriodBuilder builder, DateFormatter fallback, long fallbackLimit)

Creates a basic duration formatter with the given formatter, builder, and fallback. It's up to the caller to ensure that the locales and timezones of these are in sync.

BasicDurationFormatterback to summary
protected BasicDurationFormatter(PeriodFormatter formatter, PeriodBuilder builder, DateFormatter fallback, long fallbackLimit, String localeName, TimeZone timeZone)

Method Detail

doBuildback to summary
protected Period doBuild(long duration, long referenceDate)
doFallbackback to summary
protected String doFallback(long duration, long referenceDate)
doFormatback to summary
protected String doFormat(Period period)
formatDurationFromback to summary
public String formatDurationFrom(long duration, long referenceDate)

Implements com.ibm.icu.impl.duration.DurationFormatter.formatDurationFrom.

Doc from com.ibm.icu.impl.duration.DurationFormatter.formatDurationFrom.

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
@Override
formatDurationFromNowback to summary
public String formatDurationFromNow(long duration)

Implements com.ibm.icu.impl.duration.DurationFormatter.formatDurationFromNow.

Doc from com.ibm.icu.impl.duration.DurationFormatter.formatDurationFromNow.

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
@Override
formatDurationFromNowToback to summary
public String formatDurationFromNowTo(Date targetDate)

Implements com.ibm.icu.impl.duration.DurationFormatter.formatDurationFromNowTo.

Doc from com.ibm.icu.impl.duration.DurationFormatter.formatDurationFromNowTo.

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
@Override
withLocaleback to summary
public DurationFormatter withLocale(String locName)

Implements com.ibm.icu.impl.duration.DurationFormatter.withLocale.

Doc from com.ibm.icu.impl.duration.DurationFormatter.withLocale.

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

Parameters
locName:String

the name of the new locale

Returns:DurationFormatter

a new formatter for the given locale

Annotations
@Override
withTimeZoneback to summary
public DurationFormatter withTimeZone(TimeZone tz)

Implements com.ibm.icu.impl.duration.DurationFormatter.withTimeZone.

Doc from com.ibm.icu.impl.duration.DurationFormatter.withTimeZone.

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

Annotations
@Override