Package com.ibm.icu.impl.duration
Class BasicPeriodFormatterFactory
- java.lang.Object
-
- com.ibm.icu.impl.duration.BasicPeriodFormatterFactory
-
- All Implemented Interfaces:
PeriodFormatterFactory
public class BasicPeriodFormatterFactory extends java.lang.Object implements 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 Classes Modifier and Type Class Description (package private) static class
BasicPeriodFormatterFactory.Customizations
-
Field Summary
Fields Modifier and Type Field Description private BasicPeriodFormatterFactory.Customizations
customizations
private boolean
customizationsInUse
private PeriodFormatterData
data
private PeriodFormatterDataService
ds
private java.lang.String
localeName
-
Constructor Summary
Constructors Constructor Description BasicPeriodFormatterFactory(PeriodFormatterDataService ds)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCountVariant()
Return the count variant.(package private) PeriodFormatterData
getData()
(package private) PeriodFormatterData
getData(java.lang.String locName)
static BasicPeriodFormatterFactory
getDefault()
Return the default rdf factory as a BasicPeriodFormatterFactory.boolean
getDisplayLimit()
Return true if limits will be displayed.boolean
getDisplayPastFuture()
Return true if past and future will be displayed.PeriodFormatter
getFormatter()
Return a formatter based on this factory's current settings.int
getSeparatorVariant()
Return the variant indicating how separators will be displayed.int
getUnitVariant()
Return the unit variant.PeriodFormatterFactory
setCountVariant(int variant)
Set the variant of the count to use.PeriodFormatterFactory
setDisplayLimit(boolean display)
Set whether limits will be displayed.PeriodFormatterFactory
setDisplayPastFuture(boolean display)
Set whether past and future will be displayed.PeriodFormatterFactory
setLocale(java.lang.String localeName)
Set the locale for this factory.PeriodFormatterFactory
setSeparatorVariant(int variant)
Set how separators will be displayed.PeriodFormatterFactory
setUnitVariant(int variant)
Set the variant of the time unit names to use.private BasicPeriodFormatterFactory.Customizations
updateCustomizations()
-
-
-
Field Detail
-
ds
private final PeriodFormatterDataService ds
-
data
private PeriodFormatterData data
-
customizations
private BasicPeriodFormatterFactory.Customizations customizations
-
customizationsInUse
private boolean customizationsInUse
-
localeName
private java.lang.String localeName
-
-
Constructor Detail
-
BasicPeriodFormatterFactory
BasicPeriodFormatterFactory(PeriodFormatterDataService ds)
-
-
Method Detail
-
getDefault
public static BasicPeriodFormatterFactory getDefault()
Return the default rdf factory as a BasicPeriodFormatterFactory.- Returns:
- a default BasicPeriodFormatterFactory
-
setLocale
public PeriodFormatterFactory setLocale(java.lang.String localeName)
Set the locale for this factory.- Specified by:
setLocale
in interfacePeriodFormatterFactory
- Parameters:
localeName
- the name of the Locale- Returns:
- this PeriodFormatterFactory
-
setDisplayLimit
public PeriodFormatterFactory setDisplayLimit(boolean display)
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
public PeriodFormatterFactory setDisplayPastFuture(boolean display)
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
public PeriodFormatterFactory setSeparatorVariant(int variant)
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
public PeriodFormatterFactory setUnitVariant(int variant)
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
public PeriodFormatterFactory setCountVariant(int variant)
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
public PeriodFormatter 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
private BasicPeriodFormatterFactory.Customizations updateCustomizations()
-
getData
PeriodFormatterData getData()
-
getData
PeriodFormatterData getData(java.lang.String locName)
-
-