Format a currency ( value
, currency
) according to the given options
.
Important: Use .currencyFormatter( currency [, options] )
instead when formatting more then one number, for
improved performance.
value
Number to be formatted, eg. 9.99
.
currency
3-letter currency code as defined by ISO 4217, eg. USD
.
options Optional
See .currencyFormatter( currency [, options] )
.
You can use the static method Globalize.formatCurrency()
, which uses the default
locale.
Globalize.locale( "en" );
Globalize.formatCurrency( 1, "USD" ); // "$9.99"
Globalize.formatCurrency( 1, "EUR" ); // "€9.99"
You can use the instance method .formatCurrency()
, which uses the instance
locale.
var de = new Globalize( "de" );
de.formatCurrency( 9.99, "USD" ); // "9,99 $"
de.formatCurrency( 9.99, "EUR" ); // "9,99 €"
See .currencyFormatter( currency [, options] )
for
more examples.