Reputation: 7730
I am using Globalizejs to format Currency based on Logged-In user details in my application.
I don't want currency Symbol to be displayed when formatting is done using below code snippet:
Globalize.locale( "en" );
currencyFormatter = Globalize.currencyFormatter( "USD", {
maximumFractionDigits: 0,
});
currencyFormatter(parseInt(totalCost.amount));
which returns
$1,212,122,112 for amount: 1212122112
Is there any option similar to maximumFractionDigits
to avoid the currency symbol ?
Upvotes: 0
Views: 2368
Reputation: 2889
Short answer: Globalize.numberFormatter
Longer answer: Two benefits of using currency formatter is: (a) have the currency symbol properly formatted, and (b) have the appropriate number of fraction digits properly formatted; note that several currencies such as USD, EUR, have 2 fraction digits by default, but others like JPY have 0, there are different cases too.
The appropriate solution to customize the markup and style of a formatted output is to use parts Globalize.currencyToPartsFormatter
: At the time we speak, this feature isn't implemented yet https://github.com/globalizejs/globalize/issues/679.
As a workaround, which should work fine for your specific use case (no currency symbol + integers only amount), using Globalize.numberFormatter
should suffice.
Upvotes: 1