MonetaryAmount based
on BigDecimal as numeric representation.
As required by MonetaryAmount this class is final, thread-safe,
immutable and serializable.
This class can be configured with an arbitrary MonetaryContext. The
default MonetaryContext used models by default the same settings as
MathContext#DECIMAL64 . This default MonetaryContext can also
be reconfigured by adding a file /javamoney.properties to the
classpath, with the following content:
# Default MathContext for Money #------------------------------- # Custom MonetaryContext, overrides default entries from # org.javamoney.moneta.Money.monetaryContext # RoundingMode hereby is optional (default = HALF_EVEN) org.javamoney.moneta.Money.defaults.precision=256 org.javamoney.moneta.Money.defaults.roundingMode=HALF_EVEN
| Modifier and Type | Field and Description |
|---|---|
| private final CurrencyUnit | currency
The currency of this amount. |
| public static final MonetaryContext | DEFAULT_MONETARY_CONTEXT
The default |
| private final MonetaryContext | monetaryContext
the |
| private final BigDecimal | number
The numeric part of this amount. |
| private static final long | serialVersionUID
serialVersionUID. |
| Access | Constructor and Description |
|---|---|
| private | Money(BigDecimal
the amount, not null. number, CurrencyUnit the currency, not null. currency)Creates a new instance of |
| private | Money(BigDecimal
the amount, not number, CurrencyUnit null.the currency, not currency, MonetaryContext null.the monetaryContext)MonetaryContext, if null, the default is
used.Creates a new instance of |
| Modifier and Type | Method and Description |
|---|---|
| public Money | abs()
Implements javax. Returns a |
| public Money | add(MonetaryAmount amount)
Implements javax. Returns a |
| public static void | checkNoInfinityOrNaN(Number
the amount, not null. number)
Deprecated
Will be removed. Use
Just to don't break the compatibility. |
| public int | compareTo(MonetaryAmount o)
Implements java. Compares this object with the specified object for order. |
| private static MonetaryAmountFormat | |
| public Money | divide(long divisor)
Implements javax. Returns a |
| public Money | divide(double divisor)
Implements javax. Returns a |
| public Money | divide(Number divisor)
Implements javax. Returns a |
| public Money[] | divideAndRemainder(long divisor)
Implements javax. Returns a two-element |
| public Money[] | divideAndRemainder(double divisor)
Implements javax. Returns a two-element |
| public Money[] | divideAndRemainder(Number divisor)
Implements javax. Returns a two-element |
| public Money | divideToIntegralValue(long divisor)
Implements javax. Returns a |
| public Money | divideToIntegralValue(double divisor)
Implements javax. Returns a |
| public Money | divideToIntegralValue(Number divisor)
Implements javax. Returns a |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public static Money | Returns: an according Money instance.the amount to be converted amt)Converts (if necessary) the given |
| public MonetaryContext | Returns: theMonetaryContext used, never null.Implements javax. Access the |
| public CurrencyUnit | Returns: the currency, nevernullImplements javax. Returns the amount’s currency, modelled as |
| public MonetaryAmountFactory | getFactory()
Implements javax. Creates a new |
| public NumberValue | Returns: TheNumber representation matching best.Implements javax. Gets the number representation of the numeric value of this item. |
| public BigDecimal | Returns: the stripped number value.Method that returns BigDecimal.ZERO, if |
| public int | Returns: the precision of thisRoundedMoney.Returns the precision of this |
| public int | |
| public int | |
| public boolean | isEqualTo(MonetaryAmount amount)
Implements javax. Compares two instances of |
| public boolean | isGreaterThan(MonetaryAmount amount)
Implements javax. Compares two instances of |
| public boolean | isGreaterThanOrEqualTo(MonetaryAmount amount)
Implements javax. Compares two instances of |
| public static boolean | isInfinityAndNotNaN(Number
the amount, not null number)
Deprecated
Will be removed.
Just to don't break the compatibility. |
| public boolean | isLessThan(MonetaryAmount amount)
Implements javax. Compares two instances of |
| public boolean | isLessThanOrEqualTo(MonetaryAmount amount)
Implements javax. Compares two instances of |
| public boolean | isNegative()
Overrides default javax. Checks if a |
| public boolean | isNegativeOrZero()
Overrides default javax. Checks if a |
| public boolean | isPositive()
Overrides default javax. Checks if a |
| public boolean | isPositiveOrZero()
Overrides default javax. Checks if a |
| public boolean | |
| public Money | multiply(long multiplicand)
Implements javax. Returns a |
| public Money | multiply(double multiplicand)
Implements javax. Returns a |
| public Money | multiply(Number multiplicand)
Implements javax. Returns a |
| public Money | negate()
Implements javax. Returns a |
| public static Money | Returns: aMoney combining the numeric value and currency unit.numeric value, not number, CurrencyUnit null.currency unit, not currency)null.Creates a new instance of |
| public static Money | Returns: aMoney instance based on the monetary context with the
given numeric value, currency unit.numeric value, not number, CurrencyUnit null.currency unit, not currency, MonetaryContext monetaryContext)null.Creates a new instance of |
| public static Money | Returns: A new instance ofMoney.The numeric part, not null. number, CurrencyUnit The target currency, not null. currency)Creates a new instance of |
| public static Money | Returns: A new instance ofMoney.The numeric part, not null. number, CurrencyUnit The target currency, not null. currency, MonetaryContext monetaryContext)Creates a new instance of |
| public static Money | |
| public static Money | Returns: A new instance ofMoney.The numeric part, not null. number, String The target currency as ISO currency code. currencyCode)Static factory method for creating a new instance of |
| public static Money | |
| public static Money | Returns: A new instance ofMoney.The numeric part, not null. number, String The target currency as ISO currency code. currencyCode, MonetaryContext monetaryContext)Static factory method for creating a new instance of |
| public static Money | Returns: the Money from minor unitsthe currency currency, long the amount of money in the minor division of the currency amountMinor)Obtains an instance of |
| public static Money | Returns: the monetary amount from minor unitsthe currency, not null currency, long the amount of money in the minor division of the currency amountMinor, int number of digits fractionDigits)Obtains an instance of |
| public static Money | Returns: Money instancethe text to parse not null text)Obtains an instance of Money from a text string such as 'EUR 25.25'. |
| public static Money | Returns: Money instancethe text to parse not null text, MonetaryAmountFormat the formatter to use not null formatter)Obtains an instance of Money from a text using specific formatter. |
| public Money | |
| public <R> R | query(MonetaryQuery<R> query)
Overrides default javax. Queries this monetary amount for a value. |
| public Money | remainder(long divisor)
Implements javax. Returns a |
| public Money | remainder(double divisor)
Implements javax. Returns a |
| public Money | remainder(Number divisor)
Implements javax. Returns a |
| public Money | scaleByPowerOfTen(int power)
Implements javax. Returns a |
| public int | signum()
Implements javax. Returns the signum function of this |
| public Money | stripTrailingZeros()
Implements javax. Returns a |
| public Money | subtract(MonetaryAmount subtrahend)
Implements javax. Returns a |
| public String | |
| public Money | with(MonetaryOperator operator)
Overrides default javax. Returns an operated object of the same type as this object with the operation made. |
| public static Money | Returns: an instance ofMoney representing zero.the currency, not null. currency)Obtains an instance of |