Package com.ibm.icu.impl.duration
Class BasicDurationFormatterFactory
java.lang.Object
com.ibm.icu.impl.duration.BasicDurationFormatterFactory
- All Implemented Interfaces:
DurationFormatterFactory
Abstract factory object used to create DurationFormatters.
DurationFormatters are immutable once created.
Setters on the factory mutate the factory and return it, for chaining.
Subclasses override getFormatter to return a custom DurationFormatter.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PeriodBuilder
private BasicDurationFormatter
private DateFormatter
private long
private PeriodFormatter
private String
private BasicPeriodFormatterService
private TimeZone
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a default formatter for the current locale and time zone. -
Method Summary
Modifier and TypeMethodDescriptionprotected BasicDurationFormatter
Create the formatter.Return the current fallback formatter.long
Return the current fallback formatter limitReturn a formatter based on this factory's current settings.Return the current locale name.Return the current builder.Return the current period formatter.Return the current locale name.protected void
reset()
Clear the cached formatter.setFallback
(DateFormatter fallback) Set a fallback formatter for durations over a given limit.setFallbackLimit
(long fallbackLimit) Set a fallback limit for durations over a given limit.Set the name of the locale that will be used when creating new formatters.setPeriodBuilder
(PeriodBuilder builder) Set the builder used by the factory.setPeriodFormatter
(PeriodFormatter formatter) Set the period formatter used by the factory.setTimeZone
(TimeZone timeZone) Set the name of the locale that will be used when creating new formatters.
-
Field Details
-
ps
-
formatter
-
builder
-
fallback
-
fallbackLimit
private long fallbackLimit -
localeName
-
timeZone
-
f
-
-
Constructor Details
-
BasicDurationFormatterFactory
BasicDurationFormatterFactory(BasicPeriodFormatterService ps) Create a default formatter for the current locale and time zone.
-
-
Method Details
-
setPeriodFormatter
Set the period formatter used by the factory. New formatters created with this factory will use the given period formatter.- Specified by:
setPeriodFormatter
in interfaceDurationFormatterFactory
- Parameters:
formatter
- the formatter to use- Returns:
- this BasicDurationFormatterFactory
-
setPeriodBuilder
Set the builder used by the factory. New formatters created with this factory will use the given locale.- Specified by:
setPeriodBuilder
in interfaceDurationFormatterFactory
- Parameters:
builder
- the builder to use- Returns:
- this BasicDurationFormatterFactory
-
setFallback
Set a fallback formatter for durations over a given limit.- Specified by:
setFallback
in interfaceDurationFormatterFactory
- Parameters:
fallback
- the fallback formatter to use, or null- Returns:
- this BasicDurationFormatterFactory
-
setFallbackLimit
Set a fallback limit for durations over a given limit.- Specified by:
setFallbackLimit
in interfaceDurationFormatterFactory
- Parameters:
fallbackLimit
- the fallback limit to use, or 0 if none is desired.- Returns:
- this BasicDurationFormatterFactory
-
setLocale
Set the name of the locale that will be used when creating new formatters.- Specified by:
setLocale
in interfaceDurationFormatterFactory
- Parameters:
localeName
- the name of the Locale- Returns:
- this BasicDurationFormatterFactory
-
setTimeZone
Set the name of the locale that will be used when creating new formatters.- Specified by:
setTimeZone
in interfaceDurationFormatterFactory
- Parameters:
timeZone
- The time zone to use.- Returns:
- this BasicDurationFormatterFactory
-
getFormatter
Return a formatter based on this factory's current settings.- Specified by:
getFormatter
in interfaceDurationFormatterFactory
- Returns:
- a BasicDurationFormatter
-
getPeriodFormatter
Return the current period formatter.- Returns:
- the current period formatter
-
getPeriodBuilder
Return the current builder.- Returns:
- the current builder
-
getFallback
Return the current fallback formatter.- Returns:
- the fallback formatter, or null if there is no fallback formatter
-
getFallbackLimit
public long getFallbackLimit()Return the current fallback formatter limit- Returns:
- the limit, or 0 if there is no fallback.
-
getLocaleName
Return the current locale name.- Returns:
- the current locale name
-
getTimeZone
Return the current locale name.- Returns:
- the current locale name
-
createFormatter
Create the formatter. All local fields are already initialized. -
reset
protected void reset()Clear the cached formatter. Subclasses must call this if their state has changed. This is automatically invoked by setBuilder, setFormatter, setFallback, setLocaleName, and setTimeZone
-