public final class Money extends Quantity
Money
class represents the Euro currency. A suitable
Metric
and RoundingStrategy
is created
automatically. A user-defined Metric
can be supplied. The
default Metric
is Euro. Arithmetic functions are used from the
Quantity
class. The internal representation uses four digits
after the decimal separator.Modifier and Type | Field and Description |
---|---|
static Metric |
EURO
Convenience instance, used for the euro currency.
|
static Money |
ONE
Convenience instance, having a value of 1.
|
static Money |
OVER9000
Convenience instance, having a very high value.
|
static Money |
ZERO
Convenience instance, having a value of 0.
|
Constructor and Description |
---|
Money(java.math.BigDecimal amount)
Constructs a new
Money object from a BigDecimal
. |
Money(java.math.BigDecimal amount,
Metric metric)
Creates a new
Money instance from an amount and a metric. |
Money(double amount)
Constructs a new
Money object from a double
value |
Money(double amount,
Metric metric)
Creates a new
Money instance from an amount and a metric. |
Money(int amount,
Metric metric)
Creates a new
Money instance from an amount and a metric. |
Money(long amount)
Constructs a new
Money object from a long value |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
toString()
String representation of the monetary value represented by
this . |
add, clone, compareTo, divide, equals, getAmount, getMetric, getRoundingStrategy, greaterThan, hashCode, isNegative, lessThan, multiply, subtract
public static final Metric EURO
public static final Money ZERO
public static final Money ONE
public static final Money OVER9000
public Money(java.math.BigDecimal amount, Metric metric)
Money
instance from an amount and a metric.amount
- amount of the money represented by this instancemetric
- metric (currency) to be used for this instance.public Money(int amount, Metric metric)
Money
instance from an amount and a metric.amount
- amount of the money represented by this instancemetric
- metric (currency) to be used for this instance.public Money(double amount, Metric metric)
Money
instance from an amount and a metric.amount
- amount of the money represented by this instancemetric
- metric (currency) to be used for this instance.public Money(java.math.BigDecimal amount)
Money
object from a BigDecimal
.amount
- the amount of money represented by this
public Money(long amount)
Money
object from a long
valueamount
- the amount of money represented by this
public Money(double amount)
Money
object from a double
valueamount
- the amount of money represented by this
¸