Class NumberFormatting

java.lang.Object
com.vmware.vipclient.i18n.base.instances.NumberFormatting
All Implemented Interfaces:
Formatting, I18n

public class NumberFormatting extends Object implements Formatting
Provides functions to get the formatted number, percent, currency and so on.
  • Constructor Details

    • NumberFormatting

      public NumberFormatting()
  • Method Details

    • formatNumber

      public String formatNumber(Object value, Locale locale)
      Format a number to an localized number string in decimal style according to locale's decimal format defined in cldr. Default fraction size in cldr decimal format is: the minimum is 0, the maximum is 3.
      Parameters:
      value - The number to be formatted.
      locale - The locale for which the number format is desired.
      Returns:
      The formatted number string.
    • formatNumber

      public String formatNumber(Object value, String language, String region)
    • formatNumber

      public String formatNumber(Object value, Integer fractionSize, Locale locale)
      Format a number to an localized number string in decimal style using user self defined fraction size. cldr decimal format's fraction size will be ignored.
      Parameters:
      value - The number to be formatted.
      fractionSize - User self defined fraction size.
      locale - The locale for which the number format is desired.
      Returns:
      The formatted number string.
    • formatNumber

      public String formatNumber(Object value, Integer fractionSize, String language, String region)
      Format a number to an localized number string in decimal style using user self defined fraction size. cldr decimal format's fraction size will be ignored.
      Parameters:
      value - The number to be formatted.
      fractionSize - User self defined fraction size.
      language - The language for which the number format is desired.
      region - The region for which the number format is desired.
      Returns:
      The formatted number string.
    • formatPercent

      public String formatPercent(Object value, Locale locale)
      Format a number to an localized number string in percent style according to locale's percent format defined in cldr. Default fraction size in cldr percent format is 0.
      Parameters:
      value - The number to be formatted.
      locale - The locale for which the percent format is desired.
      Returns:
      The formatted percent string.
    • formatPercent

      public String formatPercent(Object value, String language, String region)
    • formatPercent

      public String formatPercent(Object value, Integer fractionSize, Locale locale)
      Format a number to an localized number string in percent style using user self defined fraction size. cldr percent format's fraction size will be ignored.
      Parameters:
      value - The number to be formatted.
      fractionSize - User self defined fraction size.
      locale - The locale for which the percent format is desired.
      Returns:
      The formatted percent string.
    • formatPercent

      public String formatPercent(Object value, Integer fractionSize, String language, String region)
      Format a number to an localized number string in percent style using user self defined fraction size. cldr percent format's fraction size will be ignored.
      Parameters:
      value - The number to be formatted.
      fractionSize - User self defined fraction size.
      language - The language for which the number format is desired.
      region - The region for which the number format is desired.
      Returns:
      The formatted percent string.
    • formatCurrency

      public String formatCurrency(Object amount, Locale locale)
      Format a number to an localized number string with default currency symbol($) according to locale's currency format defined in cldr. Default fraction size in cldr currency format is 2.
      Parameters:
      amount - The number to be formatted.
      locale - The locale for which the currency format is desired.
      Returns:
      The formatted currency string.
    • formatCurrency

      public String formatCurrency(Object amount, String language, String region)
    • formatCurrency

      public String formatCurrency(Object amount, String currencyCode, Locale locale)
      Format a number to an localized number string with currency symbol specified by 3-letter currency code according to locale's currency format defined in cldr. Default fraction size in cldr currency format is 2.
      Parameters:
      amount - The number to be formatted.
      currencyCode - ISO 4217 3-letter code. For all legal code please refer to https://en.wikipedia.org/wiki/ISO_4217.
      locale - The locale for which the currency format is desired.
      Returns:
      The formatted currency string.
    • formatCurrency

      public String formatCurrency(Object amount, String currencyCode, String language, String region)
      Format a number to an localized number string with currency symbol specified by 3-letter currency code according to locale's currency format defined in cldr. Default fraction size in cldr currency format is 2.
      Parameters:
      amount - The number to be formatted.
      currencyCode - ISO 4217 3-letter code. For all legal code please refer to https://en.wikipedia.org/wiki/ISO_4217.
      language - The language for which the number format is desired.
      region - The region for which the number format is desired.
      Returns:
      The formatted currency string.
    • format

      public String format(Object value, Locale locale, int style)
      Returns a specific style number format for a specific locale.
      Parameters:
      value -
      locale -
      style - number format style, currently only support NUMBERSTYLE, PERCENTSTYLE, CURRENCYSTYLE,
      Returns:
    • format

      public String format(Object value, String language, String region, int style)
    • format

      public String format(Object value, Integer fractionSize, Locale locale, int style)
      Returns a specific style number format with specified fractionSize for a specific locale.
      Parameters:
      value -
      fractionSize -
      locale -
      style - number format style, currently only support NUMBERSTYLE, PERCENTSTYLE, CURRENCYSTYLE,
      Returns:
    • format

      public String format(Object value, Integer fractionSize, String language, String region, int style)
    • format

      public String format(Object value, Integer fractionSize, String currencyCode, Locale locale, int style)
      Returns a specific style number format or currency format with specified fractionSize for a specific locale.
      Parameters:
      value -
      fractionSize -
      currencyCode -
      locale -
      style - number format style, currently only support NUMBERSTYLE, PERCENTSTYLE, CURRENCYSTYLE,
      Returns:
    • format

      public String format(Object value, Integer fractionSize, String currencyCode, String language, String region, int style)