Class NumberFormat


  • public final class NumberFormat
    extends Object
    The object is a constructor for objects that enable language sensitive number formatting.
    See MDN for more details.
    Author:
    Andrea "Stock" Stocchero
    • Constructor Summary

      Constructors 
      Constructor Description
      NumberFormat()
      Creates object that enable language sensitive number formatting, using the defualt locale.
      NumberFormat​(CLocale locale)
      Creates object that enable language sensitive number formatting, using the locale options.
      NumberFormat​(CLocale locale, NumberFormatOptions options)
      Creates object that enables language sensitive number formatting, using the locale options and specific options.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String format​(double value)
      Formats a number according to the locale and formatting options of this object.
      String format​(T value)
      Formats a value according to the locale and formatting options of this object.
      List<FormatPart> formatToParts​(double value)
      Returns an array of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts.
      It is useful for custom formatting of number strings.
      List<FormatPart> formatToParts​(T value)
      Returns an array of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts.
      It is useful for custom formatting of value strings.
      CLocale getLocale()
      Returns the locale which has initialized the format.
      R resolvedOptions()
      Returns a new object with properties reflecting the locale and value formatting options computed during initialization of this object.
    • Constructor Detail

      • NumberFormat

        public NumberFormat()
        Creates object that enable language sensitive number formatting, using the defualt locale.
      • NumberFormat

        public NumberFormat​(CLocale locale)
        Creates object that enable language sensitive number formatting, using the locale options.
        Parameters:
        locale - a locale instance
      • NumberFormat

        public NumberFormat​(CLocale locale,
                            NumberFormatOptions options)
        Creates object that enables language sensitive number formatting, using the locale options and specific options.
        Parameters:
        locale - a locale instance
        options - options to configure the number format
    • Method Detail

      • format

        public final String format​(double value)
        Formats a number according to the locale and formatting options of this object.
        Parameters:
        value - the number to format
        Returns:
        the number in the a string according to the locale and formatting options
      • formatToParts

        public final List<FormatPart> formatToParts​(double value)
        Returns an array of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts.
        It is useful for custom formatting of number strings.
        Parameters:
        value - number to format
        Returns:
        an array of objects containing the formatted number in parts.
      • getLocale

        public final CLocale getLocale()
        Returns the locale which has initialized the format.
        Returns:
        the locale which has initialized the format
      • format

        public final String format​(T value)
        Formats a value according to the locale and formatting options of this object.
        Parameters:
        value - the vale to format
        Returns:
        the value in the a string according to the locale and formatting options
      • resolvedOptions

        public final R resolvedOptions()
        Returns a new object with properties reflecting the locale and value formatting options computed during initialization of this object.
        Returns:
        new object with properties reflecting the locale and value formatting options computed during initialization of this object
      • formatToParts

        public final List<FormatPart> formatToParts​(T value)
        Returns an array of objects containing the locale-specific tokens from which it possible to build custom strings while preserving the locale-specific parts.
        It is useful for custom formatting of value strings.
        Parameters:
        value - value to format
        Returns:
        an array of objects containing the formatted value in parts.