|
SAP Convergent Charging
Java and XML APIs (Core) |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.highdeal.currency.Money
public class Money
Money is an immutable representing an amount of money with an arbitrary precision.
| Field Summary | |
|---|---|
static int |
NEAREST
Rounds toward nearest neighbor. |
static int |
RAISE
Increments the digit prior to a non-zero discarded fraction. |
static int |
TRUNCATE
Truncate the money amount. |
| Constructor Summary | |
|---|---|
Money(java.math.BigDecimal anAmount,
Currency aCurrency)
Create a new money amount for a currency and with an internal precision sets to the currency default precision. |
|
Money(java.math.BigDecimal anAmount,
Currency aCurrency,
int internalPrecision)
Create a new money amount for a currency and with an internal precision. |
|
Money(java.math.BigDecimal anAmount,
Currency aCurrency,
int internalPrecision,
int roundingMode)
Create a new money amount for a currency and with an internal precision. |
|
Money(java.math.BigDecimal anAmount,
java.lang.String currencyCode)
Create a new money amount for a currency and with an internal precision sets to the currency default precision. |
|
Money(java.math.BigDecimal anAmount,
java.lang.String currencyCode,
int internalPrecision,
int roundingMode)
Create a new money amount for a currency and with an internal precision. |
|
Money(java.lang.String s)
Creates a new money amount by parsing the string s
that must be like EUR 0.00 or USD 0.00 for instance. |
|
| Method Summary | |
|---|---|
Money |
add(Money val)
Returns a money amount whose value is the sum of this and val and whose internal precision is the maximum of the internal precisions of this and val. |
Money |
add(Money val,
int precision,
int roundingMode)
Returns a money amount whose value is the sum of this and val with a specified precision and rouding mode. |
int |
compareTo(Money val)
Returns 0 if amounts are equals (same currency and same value), -1, or 1. |
static int |
convertRounding(int rounding)
Converts a money rounding into a big decimal rounding. |
Money |
divide(java.math.BigDecimal val,
int roundingMode)
Returns a money amount whose value is the quotient of this by a value, rounded through a given rounding mode. |
Money |
divide(java.math.BigDecimal val,
int internalPrecision,
int roundingMode)
Returns a money amount whose value is the quotient of this by a value, rounded through a given rounding mode and with a given limited precision. |
Money |
duplicate()
Creates a duplicate of this money amount. |
boolean |
equals(java.lang.Object moneyAmount)
Returns true if amounts are equals (same currency and same value), false otherwise. |
java.math.BigDecimal |
getAmount()
Returns the amount for this money amount. |
Currency |
getCurrency()
Returns the currency for this money amount. |
static java.lang.String |
getRounding(int rounding)
Returns the string representation of the rounding mode corresponding to a money rounding mode. |
static int |
getRounding(java.lang.String rounding)
Returns the money rounding from a string representation of the rounding. |
int |
hashCode()
|
static boolean |
isMoneyFormat(java.lang.String s)
Tests if the String s is in money format. |
boolean |
isZero()
Returns true if amount is zero, whatever the currency, false otherwise. |
Money |
max(Money val)
Returns the maximum of this and val. |
Money |
min(Money val)
Returns the minimum of this and val. |
Money |
multiply(java.math.BigDecimal val,
int roundingMode)
Returns a money amount whose value is the multiplication of this by a value, rounded through a given rounding mode. |
Money |
multiply(java.math.BigDecimal val,
int internalPrecision,
int roundingMode)
Returns a money amount whose value is the multiplication of this by a value, rounded through a given rounding mode and with a given limited precision. |
Money |
negate()
Returns a money amount whose value is the opposite of this amount. |
Money |
round(int roundingMode)
Returns a new money amount whose value is rounded to the precision of its currency using the specified rounding mode. |
Money |
round(int precision,
int roundingMode)
Returns a new money amount whose value is rounded to the specified precision and rounding mode. |
Money |
subtract(Money val)
Returns a money amount whose value is the difference of this and val and whose internal precision is the maximum of the internal precisions of this and val. |
Money |
subtract(Money val,
int precision,
int roundingMode)
Returns a money amount whose value is the difference of this and val with a specified precision and rouding mode. |
Money |
toEMUCurrency(Currency toCurrency)
Converts the money amount to a EMU currency. |
Money |
toEuro()
Converts the money amount to Euro. |
java.lang.String |
toString()
Gives a string representation of the amount. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int NEAREST
public static final int TRUNCATE
public static final int RAISE
| Constructor Detail |
|---|
public Money(java.lang.String s)
throws java.lang.IllegalArgumentException
s
that must be like EUR 0.00 or USD 0.00 for instance.
s - the string to be parsed.
java.lang.IllegalArgumentException - a parsing error occurs
public Money(java.math.BigDecimal anAmount,
Currency aCurrency,
int internalPrecision)
anAmount - the initial money amount.aCurrency - the currency for this money amount.internalPrecision - the internal precision used for
computations.
public Money(java.math.BigDecimal anAmount,
Currency aCurrency,
int internalPrecision,
int roundingMode)
anAmount - the initial money amount.aCurrency - the currency for this money amount.internalPrecision - the internal precision used for
computations.roundingMode - the mode of rounding
NEAREST, TRUNCATE or RAISE
public Money(java.math.BigDecimal anAmount,
java.lang.String currencyCode)
anAmount - the initial amount.currencyCode - the currency code for this amount.Currency.getPrecision()
public Money(java.math.BigDecimal anAmount,
java.lang.String currencyCode,
int internalPrecision,
int roundingMode)
anAmount - the initial money amount.currencyCode - the currency code for this money amount.internalPrecision - the internal precision used for
computations.roundingMode - the mode of rounding
NEAREST, TRUNCATE or RAISE
public Money(java.math.BigDecimal anAmount,
Currency aCurrency)
anAmount - the initial amount.aCurrency - the currency for this amount.Currency.getPrecision()| Method Detail |
|---|
public boolean isZero()
public Money duplicate()
public Currency getCurrency()
public java.math.BigDecimal getAmount()
public Money negate()
public Money add(Money val)
throws IncompatibleCurrenciesException
val - The money to add.
IncompatibleCurrenciesException - if the
currencies of this and val are not equals.
public Money add(Money val,
int precision,
int roundingMode)
throws IncompatibleCurrenciesException
val - The money to add.precision - The number of digits for the precision.roundingMode - The rounding mode.
IncompatibleCurrenciesException - if the
currencies of this and val are not equals.
public Money subtract(Money val)
throws IncompatibleCurrenciesException
val - The value to subtract.
IncompatibleCurrenciesException - if the
currencies of this and val are not equals.
public Money subtract(Money val,
int precision,
int roundingMode)
throws IncompatibleCurrenciesException
val - The value to subtract.precision - The number of digits for the precision.roundingMode - The rounding mode.
IncompatibleCurrenciesException - if the
currencies of this and val are not equals.
public Money multiply(java.math.BigDecimal val,
int roundingMode)
val - The value to multiply by.roundingMode - The rounding mode.
public Money multiply(java.math.BigDecimal val,
int internalPrecision,
int roundingMode)
val - The value to multiply by.internalPrecision - The precision to use for the multiplication.roundingMode - The rounding mode.
public Money divide(java.math.BigDecimal val,
int roundingMode)
throws java.lang.ArithmeticException
val - The value to divide by.roundingMode - The rounding mode.
java.lang.ArithmeticException - if val is zero.
public Money divide(java.math.BigDecimal val,
int internalPrecision,
int roundingMode)
throws java.lang.ArithmeticException
val - The value to divide by.internalPrecision - The precision of the result.roundingMode - The rounding mode.
java.lang.ArithmeticException - if val is zero.
public Money max(Money val)
throws IncompatibleCurrenciesException
val - The value from which the maximum must be chosen.
IncompatibleCurrenciesException - if the currencies
of this and val are not the same.
public Money min(Money val)
throws IncompatibleCurrenciesException
val - The value from which the minimum must be chosen.
IncompatibleCurrenciesException - if the currencies
of this and val are not the same.public boolean equals(java.lang.Object moneyAmount)
equals in class java.lang.ObjectmoneyAmount - The amount to compare with.
public int hashCode()
hashCode in class java.lang.Object
public int compareTo(Money val)
throws IncompatibleCurrenciesException
val - The money to compare to.
IncompatibleCurrenciesException - if the currencies
of this and val are not the same.public Money round(int roundingMode)
roundingMode - The rounding mode.
public Money round(int precision,
int roundingMode)
precision - the precision.roundingMode - the rounding mode.
public java.lang.String toString()
toString in class java.lang.Object
public Money toEuro()
throws IncompatibleCurrenciesException
IncompatibleCurrenciesException - if currency of
the money is not a EMU currency.
public Money toEMUCurrency(Currency toCurrency)
throws IncompatibleCurrenciesException
toCurrency - The target EMU currency.
IncompatibleCurrenciesException - if the destination
currency is not a AMU currency.public static boolean isMoneyFormat(java.lang.String s)
s - The string to check.
public static int convertRounding(int rounding)
rounding - The money rounding.
public static int getRounding(java.lang.String rounding)
rounding - A string representation of the rounding.
public static java.lang.String getRounding(int rounding)
rounding - The string representation of the rounding mode.
|
Document Published: October 2015 (SAP CC 4.0 SP10 and Later) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||