- All Implemented Interfaces:
- Function
public class FormatNumberFunction
extends FunctionBase
implements Function
From http://docs.jsonata.org/string-functions.html:
$formatNumber(number, picture [, options])
Casts the number to a string and formats it to a decimal representation as
specified by the picture string.
The behaviour of this function is consistent with the XPath/XQuery function
fn:format-number as defined in the XPath F&O 3.1 specification. The picture
string parameter defines how the number is formatted and has the same syntax
as fn:format-number.
The optional third argument options is used to override the default locale
specific formatting characters such as the decimal separator. If supplied,
this argument must be an object containing name/value pairs specified in the
decimal format section of the XPath F&O 3.1 specification.
Examples
$formatNumber(12345.6, '#,###.00')=="12,345.60" $formatNumber(1234.5678,
"00.000e0")=="12.346e2" $formatNumber(34.555, "#0.00;(#0.00)")=="34.56"
$formatNumber(-34.555, "#0.00;(#0.00)")=="(34.56)" $formatNumber(0.14,
"01%")=="14%" $formatNumber(0.14, "###pm", {"per-mille": "pm"})=="140pm"
$formatNumber(1234.5678, "①①.①①①e①", {"zero-digit": ""})=="①②.③④⑥e②"