Class BasicDurationFormatterFactory

java.lang.Object
com.ibm.icu.impl.duration.BasicDurationFormatterFactory
All Implemented Interfaces:
DurationFormatterFactory

class BasicDurationFormatterFactory extends 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.

  • Field Details

  • Constructor Details

    • BasicDurationFormatterFactory

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

    • setPeriodFormatter

      public DurationFormatterFactory setPeriodFormatter(PeriodFormatter formatter)
      Set the period formatter used by the factory. New formatters created with this factory will use the given period formatter.
      Specified by:
      setPeriodFormatter in interface DurationFormatterFactory
      Parameters:
      formatter - the formatter to use
      Returns:
      this BasicDurationFormatterFactory
    • setPeriodBuilder

      public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder)
      Set the builder used by the factory. New formatters created with this factory will use the given locale.
      Specified by:
      setPeriodBuilder in interface DurationFormatterFactory
      Parameters:
      builder - the builder to use
      Returns:
      this BasicDurationFormatterFactory
    • setFallback

      public DurationFormatterFactory setFallback(DateFormatter fallback)
      Set a fallback formatter for durations over a given limit.
      Specified by:
      setFallback in interface DurationFormatterFactory
      Parameters:
      fallback - the fallback formatter to use, or null
      Returns:
      this BasicDurationFormatterFactory
    • 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(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(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
    • getFormatter

      public DurationFormatter getFormatter()
      Return a formatter based on this factory's current settings.
      Specified by:
      getFormatter in interface DurationFormatterFactory
      Returns:
      a BasicDurationFormatter
    • 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 String getLocaleName()
      Return the current locale name.
      Returns:
      the current locale name
    • getTimeZone

      public 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