Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public final class Money extends Object implements FastExternalizable, ObjectInputValidation, Comparable<Money>
BigDecimal, and more will be added
as needed. An ArithmeticException on any attempt to perform operations
on monetary values of different currencies.| Constructor and Description |
|---|
Money() |
Money(Currency currency,
BigDecimal value)
Will change the scale of the value to match the currency, but will not round.
|
Money(Currency currency,
long value,
int scale) |
| Modifier and Type | Method and Description |
|---|---|
Money |
add(Money augend) |
int |
compareTo(Money other)
Sorts by currency code and then value.
|
boolean |
equals(Object o)
Equal when has same currency, value, and scale.
|
Currency |
getCurrency() |
int |
getScale()
Gets the scale of this currency.
|
long |
getSerialVersionUID()
Gets the serialVersionUID for this object.
|
long |
getUnscaledValue()
Gets the unscaled value of this currency.
|
BigDecimal |
getValue() |
int |
hashCode() |
Money |
multiply(BigDecimal multiplicand)
Multiplies without rounding.
|
Money |
multiply(BigDecimal multiplicand,
RoundingMode roundingMode)
Multiplies with rounding.
|
Money |
negate()
Returns a monetary amount that is the negative of this amount.
|
void |
readExternal(ObjectInput in) |
String |
toString()
Displays the monetary value as currency symbol (in Locale-specific display) followed by value, such as $100.00
or $-100.50.
|
void |
validateObject() |
void |
writeExternal(ObjectOutput out) |
public Money(Currency currency, BigDecimal value) throws NumberFormatException
NumberFormatException - if unable to scale the value.public Money(Currency currency, long value, int scale) throws NumberFormatException
NumberFormatExceptionpublic Money()
public boolean equals(Object o)
public int compareTo(Money other)
compareTo in interface Comparable<Money>CurrencyComparatorpublic Currency getCurrency()
public BigDecimal getValue()
public long getUnscaledValue()
public int getScale()
public String toString()
public Money add(Money augend) throws ArithmeticException
ArithmeticExceptionpublic Money multiply(BigDecimal multiplicand) throws ArithmeticException
ArithmeticExceptionpublic Money multiply(BigDecimal multiplicand, RoundingMode roundingMode) throws ArithmeticException
ArithmeticExceptionpublic Money negate()
public long getSerialVersionUID()
FastExternalizablegetSerialVersionUID in interface FastExternalizablepublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void validateObject()
throws InvalidObjectException
validateObject in interface ObjectInputValidationInvalidObjectExceptionCopyright © 2000–2016 AO Industries, Inc.. All rights reserved.