public class BMoney extends BigDecimal implements Cloneable
ONE, ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_UNNECESSARY, ROUND_UP, TEN, ZERO| Constructor and Description |
|---|
BMoney()
Creates a zero BMoney with a scale according to
the currency of the current locale.
|
BMoney(BigDecimal val)
Creates a BMoney from a BigDecimal (userful for SQL)
|
BMoney(BigInteger intVal,
int scale)
Creates a BMoney value from a BigInteger.
The scale sets the comma within the given integer. |
BMoney(BMoney val,
int scale)
Creates a BMoney from a BMoney (useful to rescale)
|
BMoney(double val,
int scale)
Creates a BMoney value.
|
BMoney(int scale)
Creates a zero BMoney value.
|
BMoney(String val,
int scale)
Creates a BMoney value.
|
| Modifier and Type | Method and Description |
|---|---|
BMoney |
absolute()
Gets the absolute value.
|
BMoney |
add(BMoney val)
Adds a BMoney to this value and returns a new object.
|
protected BMoney |
alignScale(BMoney val)
Check the scale of the given money value.
|
BMoney |
clone()
Clones a BMoney value.
|
double |
divide(BMoney val)
Divides a BMoney by this value and returns a new object.
|
BMoney |
divide(double val)
Divides a BMoney by double and returns a new object.
|
BMoney |
invert()
Inverts this money value.
|
boolean |
isNegative()
Checks if this money value is negative.
|
boolean |
isPositive()
Checks if this money value is positive.
|
boolean |
isZero()
Checks if this money value is zero.
|
BMoney |
multiply(double val)
Multiplies this BMoney by a double and returns a new object.
|
BMoney |
smallestPositive()
Returns the smalles positive value.
Ex.: if scale is 2 --> 0.01 will be returned. |
BMoney |
subtract(BMoney val)
Subtracts a BMoney from this value and returns a new object.
|
String |
toWords()
Converts a money value to a string of digits as words.
The digits after the comma are ignored. |
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, toString, ulp, unscaledValue, valueOf, valueOf, valueOfbyteValue, shortValuepublic BMoney(double val,
int scale)
val - double-representation of the numberscale - the digits after comma the value should be rounded topublic BMoney(String val, int scale)
val - the stringscale - the digits after comma the value should be rounded topublic BMoney(int scale)
scale - the digits after commapublic BMoney(BigInteger intVal, int scale)
intVal - the big integerscale - the digits after commapublic BMoney(BMoney val, int scale)
val - the BMoney valuescale - the digits after comma the value should be rounded topublic BMoney(BigDecimal val)
val - the decimal valuepublic BMoney()
public boolean isNegative()
public boolean isPositive()
public boolean isZero()
public BMoney add(BMoney val)
val - the money value to addpublic BMoney subtract(BMoney val)
val - the money value to subtractpublic BMoney multiply(double val)
val - the double to multiply withpublic double divide(BMoney val)
val - the money value to multiplypublic BMoney divide(double val)
val - the value to divide this BMoney bypublic BMoney invert()
public BMoney absolute()
public BMoney smallestPositive()
public String toWords()
Example: 234,77 will become "two three four"
protected BMoney alignScale(BMoney val)
val - the value to be checkedTentackle - a domain driven enterprise framework