The CurrencyFormatter class formats a valid number as a currency value. It adjusts the decimal rounding and precision, the thousands separator, and the negative sign; it also adds a currency symbol. You place the currency symbol on either the left or the right side of the value with the alignSymbol property. The currency symbol can contain multiple characters, including blank spaces.

If an error occurs, an empty String is returned and a String that describes the error is saved to the error property. The error property can have one of the following values:

  • "Invalid value" means an invalid numeric value is passed to the format() method. The value should be a valid number in the form of a Number or a String.
  • "Invalid format" means one of the parameters contains an unusable setting.

See also:






Aligns currency symbol to the left side or the right side of the formatted number. Permitted values are "left" and "right".

See also:


Character to use as a currency symbol for a formatted number. You can use one or more characters to represent the currency symbol; for example, "$" or "YEN". You can also use empty spaces to add space between the currency character and the formatted number. When the number is a negative value, the currency symbol appears between the number and the minus sign or parentheses.


Decimal separator character to use when parsing an input string.


Decimal separator character to use when outputting formatted decimal numbers.


Number of decimal places to include in the output String. You can disable precision by setting it to -1. A value of -1 means do not change the precision. For example, if the input value is 1.453 and rounding is set to NumberBaseRoundType.NONE, return 1.453. If precision is -1 and you set some form of rounding, return a value based on that rounding type.


Specifies how to round the number.

In Haxe, you can use the following constants to set this property:

See also:


Character to use as the thousands separator in the input String.


Character to use as the thousands separator in the output string.


If true, format a negative number by preceding it with a minus "-" sign. If false, format the number surrounded by parentheses, for example (400).


If true, split the number into thousands increments by using a separator character.



Formats value as currency. If value cannot be formatted, return an empty String and write a description of the error to the error property.



Value to format.


Formatted string. Empty if an error occurs.

Inherited Variables

Defined by Formatter


Description saved by the formatter when an error occurs. For the possible values of this property, see the description of each formatter.

Subclasses must set this value in the format() method.

Inherited Methods