This class represents a quantity of money, stored as a BigDecimal amount
in a single currency.
Every currency has a certain standard number of decimal places.
This is typically 2 (Euro, British Pound, US Dollar) but might be
0 (Japanese Yen), 1 (Vietnamese Dong) or 3 (Bahrain Dinar).
The Money class is fixed to this number of decimal places.
For example, US dollars has a standard number of decimal places of 2. The major units are dollars. The minor units are cents, 100 to the dollar. This class does not allow calculations on fractions of a cent.
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final BigMoney | money
The money, not null. |
| private static final long | serialVersionUID
The serialisation version. |
| Access | Constructor and Description |
|---|---|
| private | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Money | Returns: the new instance with the amount converted to be positive, never nullReturns a copy of this monetary value with a positive amount. |
| public int | Returns: -1 if this is less than , 0 if equal, 1 if greater thanthe other monetary value, not null other)Implements java. Compares this monetary value to another. |
| public Money | Returns: the new multiplied instance, never nullthe new currency, not null currency, BigDecimal the conversion factor between the currencies, not null conversionMultipler, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value converted into another currency using the specified conversion rate, with a rounding mode used to adjust the decimal places in the result. |
| public Money | Returns: the new divided instance, never nullthe scalar value to divide by, not null valueToDivideBy, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value divided by the specified value. |
| public Money | Returns: the new divided instance, never nullthe scalar value to divide by, not null valueToDivideBy, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value divided by the specified value. |
| public Money | Returns: the new divided instance, never nullthe scalar value to divide by, not null valueToDivideBy, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value divided by the specified value. |
| public boolean | Returns: true if this instance equals the other instancethe other object to compare to, not null other)Overrides java. Checks if this monetary value equals another. |
| public BigDecimal | |
| public BigDecimal | Returns: the major units part of the amount, never nullGets the amount in major units as a |
| public int | Returns: the major units part of the amountGets the amount in major units as an |
| public long | Returns: the major units part of the amountGets the amount in major units as a |
| public BigDecimal | Returns: the minor units part of the amount, never nullGets the amount in minor units as a |
| public int | Returns: the minor units part of the amountGets the amount in minor units as an |
| public long | Returns: the minor units part of the amountGets the amount in minor units as a |
| public CurrencyUnit | |
| public int | Returns: the minor part of the amount, negative if the amount is negativeGets the minor part of the amount. |
| public int | Returns: the scale in use, typically 2 but could be 0, 1 and 3Gets the scale of the |
| public int | Returns: a suitable hash codeOverrides java. Returns a hash code for this monetary value. |
| public boolean | Returns: true is this is greater than the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is equal to another. |
| public boolean | Returns: true is this is greater than the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is greater than another. |
| public boolean | Returns: true is this is greater than or equal to the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is greater than or equal to another. |
| public boolean | Returns: true is this is less than the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is less than another. |
| public boolean | Returns: true is this is less than or equal to the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is less than or equal to another. |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if the amount is greater than zeroChecks if the amount is greater than zero. |
| public boolean | Returns: true if the amount is zero or greaterChecks if the amount is zero or greater. |
| public boolean | Returns: true if they have the same currencythe money to check, not null other)Checks if this instance and the specified instance have the same currency. |
| public boolean | |
| public Money | |
| public Money | |
| public Money | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount subtracted. |
| public Money | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value with the amount subtracted. |
| public Money | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount subtracted. |
| public Money | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value with the amount subtracted. |
| public Money | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount in major units subtracted. |
| public Money | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount in minor units subtracted. |
| public Money | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value multiplied by the specified value. |
| public Money | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value multiplied by the specified value. |
| public Money | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy)Returns a copy of this monetary value multiplied by the specified value. |
| public Money | Returns: the new instance with the amount negated, never nullReturns a copy of this monetary value with the amount negated. |
| public static Money | Returns: the new instance, never nullthe currency, not null currency, BigDecimal the amount of money, not null amount)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe currency, not null currency, BigDecimal the amount of money, not null amount, RoundingMode the rounding mode to use, not null roundingMode)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe currency, not null currency, double the amount of money, not null amount)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe currency, not null currency, double the amount of money, not null amount, RoundingMode the rounding mode to use, not null roundingMode)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe money to convert, not null moneyProvider)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe money to convert, not null moneyProvider, RoundingMode the rounding mode to use, not null roundingMode)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe currency, not null currency, long the amount of money in the major division of the currency amountMajor)Obtains an instance of |
| public static Money | Returns: the new instance, never nullthe currency, not null currency, long the amount of money in the minor division of the currency amountMinor)Obtains an instance of |
| public static Money | |
| public Money | |
| public Money | |
| public Money | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount added. |
| public Money | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value with the amount added. |
| public Money | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount added. |
| public Money | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value with the amount added. |
| public Money | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount in major units added. |
| public Money | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount in minor units added. |
| private void | |
| public Money | Returns: the new instance with the amount converted to be positive, never nullthe new scale scale, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value rounded to the specified scale without changing the current scale. |
| public BigMoney | Returns: the money instance, never nullImplements org. Implements the |
| public String | Returns: the string representation of this monetary value, never nullOverrides java. Gets the monetary value as a string. |
| public static Money | |
| public static Money | |
| public static Money | Returns: the total, never nullthe currency to total in, not null currency, Money... the monetary values to total, no null elements, not null monies)Obtains an instance of |
| public static Money | Returns: the total, never nullthe currency to total in, not null currency, Iterable<Money> the monetary values to total, no null elements, not null monies)Obtains an instance of |
| private Money | |
| public Money | Returns: the new instance with the input amount set, never nullthe monetary amount to set in the returned instance, not null amount)Returns a copy of this monetary value with the specified amount. |
| public Money | Returns: the new instance with the input amount set, never nullthe monetary amount to set in the returned instance, not null amount, RoundingMode the rounding mode to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the specified amount. |
| public Money | Returns: the new instance with the input amount set, never nullthe monetary amount to set in the returned instance, not null amount)Returns a copy of this monetary value with the specified amount using a well-defined
conversion from a |
| public Money | Returns: the new instance with the input amount set, never nullthe monetary amount to set in the returned instance, not null amount, RoundingMode the rounding mode to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the specified amount using a well-defined
conversion from a |
| public Money | Returns: the new instance with the input currency set, never nullthe currency to use, not null currency)Returns a copy of this monetary value with the specified currency. |
| public Money | Returns: the new instance with the input currency set, never nullthe currency to use, not null currency, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value with the specified currency. |
| private Object | |
| public static Money | Returns: the instance representing zero, never nullthe currency, not null currency)Obtains an instance of |