Class JsNumberFormat

java.lang.Object
io.deephaven.web.client.api.i18n.JsNumberFormat

@JsType(namespace="dh.i18n", name="NumberFormat") public class JsNumberFormat extends Object
Exported wrapper of the GWT NumberFormat, plus LongWrapper support Utility class to parse and format numbers, using the same format patterns as are supported by the standard Java implementation used in the Deephaven server and swing client. Works for numeric types including BigInteger and BigDecimal.
  • Constructor Details

    • JsNumberFormat

      public JsNumberFormat(String pattern)
      Creates a new number format instance. This generally should be avoided in favor of the static `getFormat` function, which will create and cache an instance so that later calls share the same instance.
      Parameters:
      pattern -
  • Method Details

    • getFormat

      public static JsNumberFormat getFormat(String pattern)
      a number format instance matching the specified format. If this format has not been specified before, a new instance will be created and cached for later reuse. Prefer this method to calling the constructor directly to take advantage of caching
      Parameters:
      pattern -
      Returns:
      dh.i18n.NumberFormat
    • parse

      public static double parse(String pattern, String text)
      Parses the given text using the cached format matching the given pattern.
      Parameters:
      pattern -
      text -
      Returns:
      double
    • format

      public static String format(String pattern, JsNumberFormat.NumberUnion number)
      Formats the specified number (or Java long, BigInteger or BigDecimal value) using the cached format matching the given pattern string.
      Parameters:
      pattern -
      number -
      Returns:
      String
    • parse

      public double parse(String text)
      Parses the given text using this instance's pattern into a JS Number.
      Parameters:
      text -
      Returns:
      double
    • format

      @JsIgnore public String format(double number)
    • format

      @JsIgnore public String format(LongWrapper number)
    • format

      public String format(JsNumberFormat.NumberUnion number)
      Formats the specified number (or Java `long`, `BigInteger` or `BigDecimal` value) using this instance's pattern.
      Parameters:
      number -
      Returns:
      String
    • toString

      public String toString()
      Overrides:
      toString in class Object