Class NumberFormat

java.lang.Object
org.jboss.elemento.intl.NumberFormat

@JsType(isNative=true, namespace="<global>", name="Intl.NumberFormat") public class NumberFormat extends Object
Mapping for Intl.NumberFormat.

double number = 123456.789;

console.log(numberFormat("de-DE", numberFormatOptions()
        .style(currency)
        .currency("EUR"))
        .format(number));
// Expected output: "123.456,79 €"

// The Japanese yen doesn't use a minor unit
console.log(numberFormat("ja-JP", numberFormatOptions()
        .style(currency)
        .currency("JPY"))
        .format(number));
// Expected output: "¥123,457"

// Limit to three significant digits
console.log(numberFormat("en-IN", numberFormatOptions()
        .maximumSignificantDigits(3))
        .format(number));
// Expected output: "1,23,000"
See Also:
  • Method Details

    • numberFormat

      @JsOverlay public static NumberFormat numberFormat()
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(String locale)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(Locale locale)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(String[] locales)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(Locale[] locales)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(NumberFormatOptions options)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(String locale, NumberFormatOptions options)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(Locale locale, NumberFormatOptions options)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(String[] locales, NumberFormatOptions options)
    • numberFormat

      @JsOverlay public static NumberFormat numberFormat(Locale[] locales, NumberFormatOptions options)
    • supportedLocalesOf

      public static elemental2.core.JsArray<String> supportedLocalesOf(String locale)
    • supportedLocalesOf

      public static elemental2.core.JsArray<String> supportedLocalesOf(String locale, SupportOptions options)
    • supportedLocalesOf

      public static elemental2.core.JsArray<String> supportedLocalesOf(jsinterop.base.JsArrayLike<String> locales)
    • supportedLocalesOf

      public static elemental2.core.JsArray<String> supportedLocalesOf(jsinterop.base.JsArrayLike<String> locales, SupportOptions options)
    • format

      public String format(double number)
    • formatToParts

      public elemental2.core.JsArray<jsinterop.base.JsPropertyMap<String>> formatToParts(double number)
    • formatRange

      public String formatRange(double start, double end)
    • formatRangeToParts

      public elemental2.core.JsArray<jsinterop.base.JsPropertyMap<String>> formatRangeToParts(double start, double end)
    • resolvedOptions

      public jsinterop.base.JsPropertyMap<String> resolvedOptions()