Converts that
money to this
currency and then compares the resulting amounts.
Converts that
money to this
currency and then compares the resulting amounts.
IMPORTANT NOTE: It's consistency is the one explained in the compare
method.
the other Money
object
true if this
!== that
, false otherwise
Multiplies amount by this money.
Multiplies amount by this money.
the amount to multiply by this money
a new object which is the result of multiplying amount to this money
Adds amount to this money.
Adds amount to this money.
the amount to sum to this money
a new object which is the result of summing amount to this money
Adds this money to that
.
Adds this money to that
. The result is expressed in terms of this money's currency.
the money to sum to this money
a new object which is the result of summing this money to that after converting that to this money's currency
Subtracts amount from this money.
Subtracts amount from this money.
the amount to sum to this money
a new object which is the result of summing amount to this money
Subtracts that
from this money.
Subtracts that
from this money. The result is expressed in terms of this money's currency.
the money to subtract from this money
a new object which is the result of subtracting that from this money after converting that to this money's currency
Divides amount by this money.
Divides amount by this money.
the amount to multiply by this money
a new object which is the result of multiplying amount to this money
Converts that
money to this
currency and then compares the resulting amounts.
Converts that
money to this
currency and then compares the resulting amounts.
IMPORTANT NOTE: It's consistency is the one explained in the compare
method.
the other Money
object
true if this
=== that
, false otherwise
the amount of this money
Converts that
money to this
currency and then compares the amounts.
Converts that
money to this
currency and then compares the amounts.
IMPORTANT NOTE: Be careful when using compare
since it might seem inconsistent because
if the conversion rate from, say, EUR to USD is 1.13 it's not guaranteed that the one from USD to EUR is exactly
1 / 1.13 (i.e. the inverse). For this reason, for example, you could have:
100(EUR).compare(113(USD)) > 0 == true // (1)
// but
113(USD).compare(100(EUR)) < 0 == false // (2)
This is because that
is first converted to this
currency and then the resulting
amounts are compared. The rule is as simple as the outer left currency is the base one into which all other
currencies are converted within an expression.
In the previous example (1) 113 USD is converted to EUR and then compared to 100 EUR.
In example (2) it's 100 EUR that is converted to USD and then compared. Since the conversion rates are not one
the inverse of the other you get apparently inconsistent results even if, for the provided conversions, they
are consistent.
the other Money
object
an Int
that is:
this
< that
this
> that
the currency for this money
Rounds this Money
to the given number of decimalDigits
using the provided roundingMode
Rounds this Money
to the given number of decimalDigits
using the provided roundingMode
the number of decimal digits to keep
a new Money
object whose number of decimal digits is decimalDigits
Converts this money to another money represented using otherCurrency
Converts this money to another money represented using otherCurrency
the currency to convert this money to
a new object where its currency is expressed in terms of otherCurrency
Formats this money object using a number of decimal digits equals to the decimalDigits param, which defaults to 5.
Formats this money object using a number of decimal digits equals to the decimalDigits param, which defaults to 5.
the number of decimal digits to include
a formatted string representing this money object
the string representation of this money which has, at most, 5 decimal digits. If you need to customize the
number of decimal digits use toFormattedString
instead
This is the main class of the lib. A Money is represented by its
amount
andcurrency
.the amount of this money
the currency for this money
2014-10-27