Class BasicPeriodFormatterFactory

java.lang.Object
com.ibm.icu.impl.duration.BasicPeriodFormatterFactory
All Implemented Interfaces:
PeriodFormatterFactory

public class BasicPeriodFormatterFactory extends 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.
  • Field Details

  • Constructor Details

  • Method Details

    • getDefault

      public static BasicPeriodFormatterFactory getDefault()
      Return the default rdf factory as a BasicPeriodFormatterFactory.
      Returns:
      a default BasicPeriodFormatterFactory
    • setLocale

      public PeriodFormatterFactory setLocale(String localeName)
      Set the locale for this factory.
      Specified by:
      setLocale in interface PeriodFormatterFactory
      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 interface PeriodFormatterFactory
      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 interface PeriodFormatterFactory
      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 interface PeriodFormatterFactory
      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 interface PeriodFormatterFactory
      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 interface PeriodFormatterFactory
      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 interface PeriodFormatterFactory
      Returns:
      a PeriodFormatter
    • updateCustomizations

      private BasicPeriodFormatterFactory.Customizations updateCustomizations()
    • getData

    • getData

      PeriodFormatterData getData(String locName)