Class FastDecimalFormat

  • All Implemented Interfaces:
    Serializable, Cloneable, FastFormat

    public class FastDecimalFormat
    extends Object
    implements FastFormat
    A wrapper around the java.text.DecimalFormat class. This wrapper limits the possible interactions with the wrapped format class and therefore eliminates the need to clone the choice format whenever the wrapper is cloned.
    Author:
    Thomas Morgner
    See Also:
    Serialized Form
    • Field Detail

      • TYPE_DEFAULT

        public static final int TYPE_DEFAULT
        A format-type constant indicating the system's default number format.
        See Also:
        Constant Field Values
      • TYPE_INTEGER

        public static final int TYPE_INTEGER
        A format-type constant indicating the system's default integer format.
        See Also:
        Constant Field Values
      • TYPE_CURRENCY

        public static final int TYPE_CURRENCY
        A format-type constant indicating the system's default currency format.
        See Also:
        Constant Field Values
      • TYPE_PERCENT

        public static final int TYPE_PERCENT
        A format-type constant indicating the system's default percentage format.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FastDecimalFormat

        public FastDecimalFormat​(String pattern)
        Creates a new decimal-format for the given pattern.
        Parameters:
        pattern - the pattern string.
      • FastDecimalFormat

        public FastDecimalFormat​(String pattern,
                                 Locale locale)
        Creates a new decimal-format for the given pattern and locale.
        Parameters:
        pattern - the pattern string.
        locale - the locale.
      • FastDecimalFormat

        public FastDecimalFormat​(int type,
                                 Locale locale)
        Creates a new date-format for the given default date and time style.
        Parameters:
        type - the number-style, one of TYPE_INTEGER, TYPE_PERCENT, TYPE_CURRENCY or TYPE_DEFAULT.
        locale - the locale.
        Throws:
        IllegalArgumentException - if both date and time-style are set to -1.
      • FastDecimalFormat

        public FastDecimalFormat​(int type,
                                 Locale locale,
                                 boolean useFormattingFromResources)
        Creates a new date-format for the given default date and time style.
        Parameters:
        type - the number-style, one of TYPE_INTEGER, TYPE_PERCENT, TYPE_CURRENCY or TYPE_DEFAULT.
        locale - the locale.
        useFormattingFromResources - always use formatting specified in resources
        Throws:
        IllegalArgumentException - if both date and time-style are set to -1.
    • Method Detail

      • getLocale

        public Locale getLocale()
        Returns the current locale of the formatter.
        Specified by:
        getLocale in interface FastFormat
        Returns:
        the current locale, never null.
      • getPattern

        public String getPattern()
        Returns the currently active pattern.
        Returns:
        the locale.
      • format

        public String format​(Object parameters)
        Formats the given object in a formatter-specific way.
        Specified by:
        format in interface FastFormat
        Parameters:
        parameters - the parameters for the formatting.
        Returns:
        the formatted string.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object