Creating Money
The Money2 package provide a number of methods to create a
Money
instance.- Money.fromInt - from a minorUnit (e.g. cents)
- Money.fromBigInt - from a minorUnit
- Money.parse - parse a monetary string containing an amount.
- Money.fromNum - from a num (int or double) - not recommended
- Currency.parse - parse a monetary string assuming the currency
- Currencies.parse - parse a monetary amount and determine the currency from theembedded currency code.
The
Money
variants all require you to pass in the Currency or a currency code
. The Currency
variant requires only the monetary value. The Currencies
variant is able to determine the Currency
if the passed string amount contains a currency code.The two most common methods are:
- Money.fromFixed
- Currency.parse
Last modified 1yr ago