Package io.deephaven.web.client.api.i18n
Class JsNumberFormat
java.lang.Object
io.deephaven.web.client.api.i18n.JsNumberFormat
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat
(double number) format
(JsNumberFormat.NumberUnion number) Formats the specified number (or Java `long`, `BigInteger` or `BigDecimal` value) using this instance's pattern.format
(LongWrapper number) 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.static JsNumberFormat
a number format instance matching the specified format.double
Parses the given text using this instance's pattern into a JS Number.static double
Parses the given text using the cached format matching the given pattern.toString()
-
Constructor Details
-
JsNumberFormat
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
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
Parses the given text using the cached format matching the given pattern.- Parameters:
pattern
-text
-- Returns:
- double
-
format
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
Parses the given text using this instance's pattern into a JS Number.- Parameters:
text
-- Returns:
- double
-
format
-
format
-
format
Formats the specified number (or Java `long`, `BigInteger` or `BigDecimal` value) using this instance's pattern.- Parameters:
number
-- Returns:
- String
-
toString
-