Class PluralFormat


  • public class PluralFormat
    extends Object
    • Constructor Detail

      • PluralFormat

        public PluralFormat​(String pattern)
      • PluralFormat

        public PluralFormat​(Locale locale,
                            String pattern)
    • Method Detail

      • applyPattern

        public void applyPattern​(String pattern)
        Sets the pattern used by this plural format. The method parses the pattern and creates a map of format strings for the plural rules. Patterns and their interpretation are specified in the class description.
        Parameters:
        pattern - the pattern for this plural format.
        Throws:
        IllegalArgumentException - if the pattern is invalid.
      • format

        public final String format​(double number)
      • format

        public StringBuilder format​(Object number,
                                    StringBuilder toAppendTo,
                                    FieldPosition pos)
        Formats a plural message for a given number and appends the formatted message to the given StringBuffer.
        Parameters:
        number - a number object (instance of Number for which the plural message should be formatted. If no pattern has been applied to this PluralFormat object yet, the formatted number will be returned. Note: If this object is not an instance of Number, the toAppendTo will not be modified.
        toAppendTo - the formatted message will be appended to this StringBuffer.
        pos - will be ignored by this method.
        Returns:
        the string buffer passed in as toAppendTo, with formatted text appended.
        Throws:
        IllegalArgumentException - if number is not an instance of Number