Class 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.
    • 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 interface PeriodFormatterFactory
        Parameters:
        localeName - the name of the Locale
        Returns:
        this PeriodFormatterFactory
      • getDisplayLimit

        public boolean getDisplayLimit()
        Return true if limits will be displayed.
        Returns:
        true if limits will be displayed
      • getDisplayPastFuture

        public boolean getDisplayPastFuture()
        Return true if past and future will be displayed.
        Returns:
        true if past and future will be displayed
      • getSeparatorVariant

        public int getSeparatorVariant()
        Return the variant indicating how separators will be displayed.
        Returns:
        the variant
      • getUnitVariant

        public int getUnitVariant()
        Return the unit variant.
        Returns:
        the unit variant
      • getCountVariant

        public int getCountVariant()
        Return the count variant.
        Returns:
        the count variant