money2
  • Overview
  • Common Currencies
  • Creating a Currency
  • Registering a Currency
  • Parsing
  • Find a currency
  • Default format
  • Symbols
  • Separators
    • Decimal Separator
    • Group Separator
  • Creating Money
    • Money.parse
    • Currency.parse
    • Money.from
    • Currencies.parse
    • decimalDigits
  • Formatting
    • Formatting Patterns
  • Storing and Send
  • Exchange Rates
  • Comparison
  • Currency Predicates
  • Value Sign Predicates
  • Arithmetic Operations
  • Allocation
  • Money encoding/decoding
Powered by GitBook
On this page

Was this helpful?

Creating Money

PreviousGroup SeparatorNextMoney.parse

Last updated 1 month ago

Was this helpful?

The Money2 package provide a number of methods to create a Money instance.

  • Money.fromFixed - from a instance.

  • Money.fromInt - from a minorUnit (e.g. cents) stored as an int.

  • Money.fromBigInt - from a minorUnit stored as a BigInt.

  • Money.parse - parse a string containing an amount.

  • Money.fromNum - from a num (int or double) - not recommended

  • Money.fromDecimal - from a

  • Currency.parse - parse a string containing a monetary amount and assumes the currency

  • Currencies.parse - parse a monetary string and determine the currency from the

    embedded ISO currency code.

The Money variants all require you to pass in the Currency or a currency code (isoCode). The Currency variant requires only the monetary value. The Currencies variant is able to determine Currency if the passed string amount contains a currency code.

The two most common methods are:

  • Money.fromFixed

  • Currency.parse

Fixed
Decimal