Package com.ibm.icu.impl.duration
Class BasicPeriodFormatterFactory
java.lang.Object
com.ibm.icu.impl.duration.BasicPeriodFormatterFactory
- All Implemented Interfaces:
PeriodFormatterFactory
An implementation of PeriodFormatterFactory that provides customization of
formatting behavior. Instances of this factory are created by
BasicPeriodFormatterService.
The settings on BasicPeriodFormatterFactory are:
- setDisplayLimit controls whether phrases like 'more than' or 'less than' will be displayed when the Period has a defined limit. Default is to display them.
- setDisplayPastFuture controls whether phrases like 'ago' or 'from now' will be displayed to indicate past or future time. Default is to display them.
- setSeparatorVariant controls how separators (between count and period, and multiple periods) will be displayed, when appropriate for the language. Default is to use full separators.
- setUnitVariant controls which of various types of unit names to use. PLURALIZED indicates that full names will be used. MEDIUM indicates that medium-length (usually 2-3 character) names will be used. SHORT indicates that short (usually single character) names will be used. If there is no localization data available for either the SHORT or MEDIUM names, the other will be used, if neither is available, the PLURALIZED names will be used. Default is PLURALIZED.
- setCountVariant controls how the count for the smallest unit will be formatted: either as an integer, a fraction to the smallest half, or as a decimal with 1, 2, or 3 decimal points. Counts for higher units will be formatted as integers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private PeriodFormatterData
private final PeriodFormatterDataService
private String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Return the count variant.(package private) PeriodFormatterData
getData()
(package private) PeriodFormatterData
static BasicPeriodFormatterFactory
Return the default rdf factory as a BasicPeriodFormatterFactory.boolean
Return true if limits will be displayed.boolean
Return true if past and future will be displayed.Return a formatter based on this factory's current settings.int
Return the variant indicating how separators will be displayed.int
Return the unit variant.setCountVariant
(int variant) Set the variant of the count to use.setDisplayLimit
(boolean display) Set whether limits will be displayed.setDisplayPastFuture
(boolean display) Set whether past and future will be displayed.Set the locale for this factory.setSeparatorVariant
(int variant) Set how separators will be displayed.setUnitVariant
(int variant) Set the variant of the time unit names to use.
-
Field Details
-
ds
-
data
-
customizations
-
customizationsInUse
private boolean customizationsInUse -
localeName
-
-
Constructor Details
-
BasicPeriodFormatterFactory
BasicPeriodFormatterFactory(PeriodFormatterDataService ds)
-
-
Method Details
-
getDefault
Return the default rdf factory as a BasicPeriodFormatterFactory.- Returns:
- a default BasicPeriodFormatterFactory
-
setLocale
Set the locale for this factory.- Specified by:
setLocale
in interfacePeriodFormatterFactory
- Parameters:
localeName
- the name of the Locale- Returns:
- this PeriodFormatterFactory
-
setDisplayLimit
Set whether limits will be displayed.- Specified by:
setDisplayLimit
in interfacePeriodFormatterFactory
- Parameters:
display
- true if limits will be displayed- Returns:
- this PeriodFormatterFactory
-
getDisplayLimit
public boolean getDisplayLimit()Return true if limits will be displayed.- Returns:
- true if limits will be displayed
-
setDisplayPastFuture
Set whether past and future will be displayed.- Specified by:
setDisplayPastFuture
in interfacePeriodFormatterFactory
- Parameters:
display
- true if past and future will be displayed- Returns:
- this PeriodFormatterFactory
-
getDisplayPastFuture
public boolean getDisplayPastFuture()Return true if past and future will be displayed.- Returns:
- true if past and future will be displayed
-
setSeparatorVariant
Set how separators will be displayed.- Specified by:
setSeparatorVariant
in interfacePeriodFormatterFactory
- Parameters:
variant
- the variant indicating separators will be displayed- Returns:
- this PeriodFormatterFactory
-
getSeparatorVariant
public int getSeparatorVariant()Return the variant indicating how separators will be displayed.- Returns:
- the variant
-
setUnitVariant
Set the variant of the time unit names to use.- Specified by:
setUnitVariant
in interfacePeriodFormatterFactory
- Parameters:
variant
- the variant to use- Returns:
- this PeriodFormatterFactory
-
getUnitVariant
public int getUnitVariant()Return the unit variant.- Returns:
- the unit variant
-
setCountVariant
Set the variant of the count to use.- Specified by:
setCountVariant
in interfacePeriodFormatterFactory
- Parameters:
variant
- the variant to use- Returns:
- this PeriodFormatterFactory
-
getCountVariant
public int getCountVariant()Return the count variant.- Returns:
- the count variant
-
getFormatter
Description copied from interface:PeriodFormatterFactory
Return a formatter based on this factory's current settings.- Specified by:
getFormatter
in interfacePeriodFormatterFactory
- Returns:
- a PeriodFormatter
-
updateCustomizations
-
getData
PeriodFormatterData getData() -
getData
-