Class PeriodFormatterData


  • public class PeriodFormatterData
    extends java.lang.Object
    PeriodFormatterData provides locale-specific data used to format relative dates and times, and convenience api to access it. An instance of PeriodFormatterData is usually created by requesting data for a given locale from an PeriodFormatterDataService.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean allowZero()
      Return true if zeros are allowed in the display.
      int appendCount​(TimeUnit unit, boolean omitCount, boolean useDigitPrefix, int count, int cv, boolean useSep, java.lang.String name, boolean last, java.lang.StringBuffer sb)
      Append a count to the string builder.
      void appendCountValue​(int count, int integralDigits, int decimalDigits, java.lang.StringBuffer sb)
      Append a count value to the builder.
      void appendDigits​(long num, int mindigits, int maxdigits, java.lang.StringBuffer sb)
      Append digits to the string builder, using this.zero for '0' etc.
      void appendInteger​(int num, int mindigits, int maxdigits, java.lang.StringBuffer sb)  
      boolean appendPrefix​(int tl, int td, java.lang.StringBuffer sb)
      Append the appropriate prefix to the string builder, depending on whether and how a limit and direction are to be displayed.
      void appendSkippedUnit​(java.lang.StringBuffer sb)
      Append a marker for skipped units internal to a string.
      void appendSuffix​(int tl, int td, java.lang.StringBuffer sb)
      Append the appropriate suffix to the string builder, depending on whether and how a limit and direction are to be displayed.
      boolean appendUnit​(TimeUnit unit, int count, int cv, int uv, boolean useCountSep, boolean useDigitPrefix, boolean multiple, boolean last, boolean wasSkipped, java.lang.StringBuffer sb)
      Append the count and unit to the string builder.
      boolean appendUnitSeparator​(TimeUnit unit, boolean longSep, boolean afterFirst, boolean beforeLast, java.lang.StringBuffer sb)
      Append the appropriate separator between units
      private int computeForm​(TimeUnit unit, int count, int cv, boolean lastOfMultiple)  
      int pluralization()
      Return the pluralization format used by this locale.
      int useMilliseconds()  
      boolean weeksAloneOnly()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PeriodFormatterData

        public PeriodFormatterData​(java.lang.String localeName,
                                   DataRecord dr)
    • Method Detail

      • pluralization

        public int pluralization()
        Return the pluralization format used by this locale.
        Returns:
        the pluralization format
      • allowZero

        public boolean allowZero()
        Return true if zeros are allowed in the display.
        Returns:
        true if zeros should be allowed
      • weeksAloneOnly

        public boolean weeksAloneOnly()
      • useMilliseconds

        public int useMilliseconds()
      • appendPrefix

        public boolean appendPrefix​(int tl,
                                    int td,
                                    java.lang.StringBuffer sb)
        Append the appropriate prefix to the string builder, depending on whether and how a limit and direction are to be displayed.
        Parameters:
        tl - how and whether to display the time limit
        td - how and whether to display the time direction
        sb - the string builder to which to append the text
        Returns:
        true if a following digit will require a digit prefix
      • appendSuffix

        public void appendSuffix​(int tl,
                                 int td,
                                 java.lang.StringBuffer sb)
        Append the appropriate suffix to the string builder, depending on whether and how a limit and direction are to be displayed.
        Parameters:
        tl - how and whether to display the time limit
        td - how and whether to display the time direction
        sb - the string builder to which to append the text
      • appendUnit

        public boolean appendUnit​(TimeUnit unit,
                                  int count,
                                  int cv,
                                  int uv,
                                  boolean useCountSep,
                                  boolean useDigitPrefix,
                                  boolean multiple,
                                  boolean last,
                                  boolean wasSkipped,
                                  java.lang.StringBuffer sb)
        Append the count and unit to the string builder.
        Parameters:
        unit - the unit to append
        count - the count of units, * 1000
        cv - the format to use for displaying the count
        uv - the format to use for displaying the unit
        useCountSep - if false, force no separator between count and unit
        useDigitPrefix - if true, use the digit prefix
        multiple - true if there are multiple units in this string
        last - true if this is the last unit
        wasSkipped - true if the unit(s) before this were skipped
        sb - the string builder to which to append the text
        Returns:
        true if will require skip marker
      • appendCount

        public int appendCount​(TimeUnit unit,
                               boolean omitCount,
                               boolean useDigitPrefix,
                               int count,
                               int cv,
                               boolean useSep,
                               java.lang.String name,
                               boolean last,
                               java.lang.StringBuffer sb)
        Append a count to the string builder.
        Parameters:
        unit - the unit
        count - the count
        cv - the format to use for displaying the count
        useSep - whether to use the count separator, if available
        name - the term name
        last - true if this is the last unit to be formatted
        sb - the string builder to which to append the text
        Returns:
        index to use if might have required or optional suffix, or -1 if none required
      • appendCountValue

        public void appendCountValue​(int count,
                                     int integralDigits,
                                     int decimalDigits,
                                     java.lang.StringBuffer sb)
        Append a count value to the builder.
        Parameters:
        count - the count
        integralDigits - the number of integer digits to display
        decimalDigits - the number of decimal digits to display, <= 3
        sb - the string builder to which to append the text
      • appendInteger

        public void appendInteger​(int num,
                                  int mindigits,
                                  int maxdigits,
                                  java.lang.StringBuffer sb)
      • appendDigits

        public void appendDigits​(long num,
                                 int mindigits,
                                 int maxdigits,
                                 java.lang.StringBuffer sb)
        Append digits to the string builder, using this.zero for '0' etc.
        Parameters:
        num - the integer to append
        mindigits - the minimum number of digits to append
        maxdigits - the maximum number of digits to append
        sb - the string builder to which to append the text
      • appendSkippedUnit

        public void appendSkippedUnit​(java.lang.StringBuffer sb)
        Append a marker for skipped units internal to a string.
        Parameters:
        sb - the string builder to which to append the text
      • appendUnitSeparator

        public boolean appendUnitSeparator​(TimeUnit unit,
                                           boolean longSep,
                                           boolean afterFirst,
                                           boolean beforeLast,
                                           java.lang.StringBuffer sb)
        Append the appropriate separator between units
        Parameters:
        unit - the unit to which to append the separator
        afterFirst - true if this is the first unit formatted
        beforeLast - true if this is the next-to-last unit to be formatted
        sb - the string builder to which to append the text
        Returns:
        true if a prefix will be required before a following unit
      • computeForm

        private int computeForm​(TimeUnit unit,
                                int count,
                                int cv,
                                boolean lastOfMultiple)