|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Number
java.math.BigDecimal
com.knowgate.math.Money
public class Money
Combination of BigDecimal with Currency Sign
This class handles money amounts that include a currency sign
| Field Summary |
|---|
| Fields inherited from class java.math.BigDecimal |
|---|
ONE, ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_UNNECESSARY, ROUND_UP, TEN, ZERO |
| Constructor Summary | |
|---|---|
Money(java.math.BigDecimal oVal,
CurrencyCode oCur)
|
|
Money(java.math.BigDecimal oVal,
java.lang.String sCur)
|
|
Money(java.math.BigInteger oVal,
CurrencyCode oCur)
|
|
Money(java.math.BigInteger oVal,
java.lang.String sCur)
|
|
Money(double dVal,
CurrencyCode oCur)
Constructor |
|
Money(double dVal,
java.lang.String sCur)
Constructor |
|
Money(Money oVal)
Constructor that makes a copy from another Money value |
|
Money(java.lang.String sVal,
CurrencyCode oCur)
Constructor |
|
Money(java.lang.String sVal,
java.lang.String sCur)
Constructor |
|
| Method Summary | |
|---|---|
Money |
add(Money oMny)
Add two money amounts The return value is in the currency of this object. |
int |
compareTo(Money oMny)
|
Money |
convertTo(CurrencyCode oTarget)
Convert this money to another currency using a web service for finding the conversion ratio |
Money |
convertTo(CurrencyCode oTarget,
java.math.BigDecimal oRatio)
Convert this money to another currency |
Money |
convertTo(java.lang.String sTarget)
Convert this money to another currency using a web service for finding the conversion ratio |
Money |
convertTo(java.lang.String sTarget,
java.math.BigDecimal oRatio)
Convert this money to another currency |
CurrencyCode |
currencyCode()
|
java.lang.String |
format(java.lang.String sLanguage,
java.lang.String sCountry)
Format a BigDecimal as a String following the rules for an specific language and country |
static boolean |
isMoney(java.lang.String sVal)
Checks whether the given string can be parsed as a valid Money value Both comma and dot are allowed as either thousands or decimal delimiters. |
Money |
max(Money oMny)
|
Money |
min(Money oMny)
|
static Money |
parse(java.lang.String sVal)
|
Money |
round2()
Rounds a BigDecimal value to two decimals |
Money |
subtract(Money oMny)
Subtract two money amounts The return value is in the currency of this object. |
java.lang.String |
toString()
|
| Methods inherited from class java.math.BigDecimal |
|---|
abs, abs, add, add, byteValueExact, compareTo, divide, divide, divide, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideToIntegralValue, divideToIntegralValue, doubleValue, equals, floatValue, hashCode, intValue, intValueExact, longValue, longValueExact, max, min, movePointLeft, movePointRight, multiply, multiply, negate, negate, plus, plus, pow, pow, precision, remainder, remainder, round, scale, scaleByPowerOfTen, setScale, setScale, setScale, shortValueExact, signum, stripTrailingZeros, subtract, subtract, toBigInteger, toBigIntegerExact, toEngineeringString, toPlainString, ulp, unscaledValue, valueOf, valueOf, valueOf |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Money(Money oVal)
public Money(java.lang.String sVal,
CurrencyCode oCur)
throws java.lang.NumberFormatException
sVal - String Numeric value in US decimal format (using dot as decimal delimiter)oCur - CurrencyCode
java.lang.NumberFormatException
public Money(java.lang.String sVal,
java.lang.String sCur)
throws java.lang.NumberFormatException,
java.lang.IllegalArgumentException
sVal - String Numeric value in US decimal format (using dot as decimal delimiter)sCur - String Currency alphanumeric code {"USD", "EUR", etc.}
java.lang.NumberFormatException
java.lang.IllegalArgumentException
public Money(double dVal,
CurrencyCode oCur)
dVal - doubleoCur - CurrencyCode
public Money(double dVal,
java.lang.String sCur)
throws java.lang.IllegalArgumentException
dVal - doublesCur - String Currency alphanumeric code {"USD", "EUR", etc.}
java.lang.IllegalArgumentException
public Money(java.math.BigDecimal oVal,
CurrencyCode oCur)
public Money(java.math.BigDecimal oVal,
java.lang.String sCur)
public Money(java.math.BigInteger oVal,
CurrencyCode oCur)
public Money(java.math.BigInteger oVal,
java.lang.String sCur)
| Method Detail |
|---|
public CurrencyCode currencyCode()
public int compareTo(Money oMny)
public Money max(Money oMny)
public Money min(Money oMny)
public Money add(Money oMny)
throws java.lang.NullPointerException
Add two money amounts
The return value is in the currency of this object. If the added amount does not have the same currency then it is converted by calling a web service before performing addition. The scale of the returned value is max(this.scale(), oMny.scale()).
java.lang.NullPointerException
public Money subtract(Money oMny)
throws java.lang.NullPointerException
Subtract two money amounts
The return value is in the currency of this object. If the added amount does not have the same currency then it is converted by calling a web service before performing addition. The scale of the returned value is max(this.scale(), oMny.scale()).
java.lang.NullPointerExceptionpublic static boolean isMoney(java.lang.String sVal)
Checks whether the given string can be parsed as a valid Money value
Both comma and dot are allowed as either thousands or decimal delimiters. If there is only a comma or a dot then it is assumed to be de decimal delimiter. If both comma and dot are present, then the leftmost of them is assumed to be the thousands delimiter and the rightmost is the decimal delimiter. Any letters and currency symbols {€$£¤¢¥#ƒ&} are ignored
public static Money parse(java.lang.String sVal)
throws java.lang.NullPointerException,
java.lang.IllegalArgumentException,
java.lang.NumberFormatException
java.lang.NullPointerException
java.lang.IllegalArgumentException
java.lang.NumberFormatExceptionpublic Money round2()
public Money convertTo(CurrencyCode oTarget,
java.math.BigDecimal oRatio)
throws java.lang.NullPointerException
Convert this money to another currency
oTarget - Target CurrencyCodeoRatio - BigDecimal Conversion ratio
java.lang.NullPointerException - if oTarget is null
public Money convertTo(java.lang.String sTarget,
java.math.BigDecimal oRatio)
throws java.lang.NullPointerException,
java.lang.IllegalArgumentException
Convert this money to another currency
oTarget - Target CurrencyCodeoRatio - BigDecimal Conversion ratio
java.lang.NullPointerException - if oTarget is null
java.lang.IllegalArgumentException
public Money convertTo(CurrencyCode oTarget)
throws java.lang.NullPointerException,
java.lang.NumberFormatException
Convert this money to another currency using a web service for finding the conversion ratio
oTarget - Target CurrencyCode
java.lang.NullPointerException - if oTarget is null
java.lang.NumberFormatException
public Money convertTo(java.lang.String sTarget)
throws java.lang.NullPointerException,
java.lang.NumberFormatException,
java.lang.IllegalArgumentException
Convert this money to another currency using a web service for finding the conversion ratio
sTarget - 3 letter Code of Target Currency
java.lang.NullPointerException - if oTarget is null
java.lang.IllegalArgumentException - if sTarget is not a valid currency code
java.lang.NumberFormatException
public java.lang.String format(java.lang.String sLanguage,
java.lang.String sCountry)
sLanguage - String ISO-639 two letter language codesCountry - String ISO-3166 two leter country code
public java.lang.String toString()
toString in class java.math.BigDecimal
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||