Creating Money

The Money2 package provide a number of methods to create a Money instance.
  • Money.fromFixed - from a Fixed decimal
  • 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
  • Money.fromDecimal - from a Decimal
  • Currency.parse - parse a monetary string assuming the currency
  • Currencies.parse - parse a monetary amount and determine the currency from the
    embedded 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