Carrot reference
Functions

formatMoney()

Converts a given value of type Money into a String, while retaining the currency type in the String output. Optionally specify the format and locale of the returned value.

Syntax

formatMoney(money[, format][, locale])

  • money - the Money value to be converted to a String
  • format - a formatting string that uses Java's DecimalFormat to format the number. For example, #.00 will format the returned value to two decimal places. Learn how to use DecimalFormat here, and view additional examples of DecimalFormat here.
  • locale - an ISO 639-1 language code, optionally followed by an ISO 3166-1 country code, used to apply proper localization settings to the returned value. For example, en-US will format the returned value using US English settings, whereas en-GB will format using British English and fr-CA will format using French Canadian settings. If locale is not passed, it will use the org's default locale (typically en-US).
  • Return type: String

Sample usage

formatMoney(base) returns the value of base as a String, including the currency symbol.

Supported data types

Input type

Return type

Logic

Money

String

If a Money value is passed, it's value will returned as a String, including the currency symbol.

Unsupported data types

Null

Unsupported data types return Null.