Class BasicDurationFormatterFactory

  • All Implemented Interfaces:
    DurationFormatterFactory

    class BasicDurationFormatterFactory
    extends java.lang.Object
    implements 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.

    • Constructor Detail

      • BasicDurationFormatterFactory

        BasicDurationFormatterFactory​(BasicPeriodFormatterService ps)
        Create a default formatter for the current locale and time zone.
    • Method Detail

      • setFallbackLimit

        public DurationFormatterFactory setFallbackLimit​(long fallbackLimit)
        Set a fallback limit for durations over a given limit.
        Specified by:
        setFallbackLimit in interface DurationFormatterFactory
        Parameters:
        fallbackLimit - the fallback limit to use, or 0 if none is desired.
        Returns:
        this BasicDurationFormatterFactory
      • setLocale

        public DurationFormatterFactory setLocale​(java.lang.String localeName)
        Set the name of the locale that will be used when creating new formatters.
        Specified by:
        setLocale in interface DurationFormatterFactory
        Parameters:
        localeName - the name of the Locale
        Returns:
        this BasicDurationFormatterFactory
      • setTimeZone

        public DurationFormatterFactory setTimeZone​(java.util.TimeZone timeZone)
        Set the name of the locale that will be used when creating new formatters.
        Specified by:
        setTimeZone in interface DurationFormatterFactory
        Parameters:
        timeZone - The time zone to use.
        Returns:
        this BasicDurationFormatterFactory
      • getPeriodFormatter

        public PeriodFormatter getPeriodFormatter()
        Return the current period formatter.
        Returns:
        the current period formatter
      • getPeriodBuilder

        public PeriodBuilder getPeriodBuilder()
        Return the current builder.
        Returns:
        the current builder
      • getFallback

        public DateFormatter 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

        public java.lang.String getLocaleName()
        Return the current locale name.
        Returns:
        the current locale name
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Return the current locale name.
        Returns:
        the current locale name
      • createFormatter

        protected BasicDurationFormatter 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