public class Money extends Object implements Serializable, Comparable<Money>, Cloneable
Long numeric for minor currency unit representation.| 限定符和类型 | 类和说明 |
|---|---|
static class |
Money.Fastjson
Custom deserialize Money based fastjson.
|
static class |
Money.JacksonDeserializer
Custom deserialize Money based jackson.
|
static class |
Money.JacksonSerializer
Custom serialize Money based jackson.
|
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
FIELD_NAME_CURRENCY |
static String |
FIELD_NAME_NUMBER |
| 构造器和说明 |
|---|
Money(Currency currency,
long number) |
Money(Currency currency,
long majorUnitNumber,
int minorUnitNumber)
Creates a MultiCurrencyMoney with majorUnitNumber, minorUnitNumber and currency
|
| 限定符和类型 | 方法和说明 |
|---|---|
Money |
add(Money other)
Returns new Money object of the two money addition
|
Money |
addTo(Money other)
This money addition other money
|
Money |
clone()
Returns this object's clone
|
int |
compareTo(Money other)
Compares with other money object.
|
Money |
divide(BigDecimal val) |
Money |
divide(BigDecimal val,
RoundingMode roundingMode) |
Money |
divideBy(BigDecimal val) |
Money |
divideBy(BigDecimal val,
RoundingMode roundingMode) |
boolean |
equals(Money other)
Returns boolean of equals other money object
|
boolean |
equals(Object other)
Returns the specified object is the same currency and has same amount
|
Currency |
getCurrency()
Returns currency
|
String |
getCurrencyCode()
Returns currency code
|
int |
getFactor()
Returns currency scaling factor
|
long |
getNumber() |
boolean |
greaterThan(Money other)
Compares is greater than other money.
|
int |
hashCode()
Return this object's hash code
|
Money |
multiply(BigDecimal val)
Returns new Money object of this money multiply value
|
Money |
multiply(BigDecimal val,
RoundingMode roundingMode)
Returns new Money object of this money multiply value
|
Money |
multiply(long val)
Returns new Money object of this money multiply value
|
Money |
multiplyBy(BigDecimal val)
This money multiply value factor
|
Money |
multiplyBy(BigDecimal val,
RoundingMode roundingMode)
This money multiply value factor
|
Money |
multiplyBy(long val)
This money multiply value factor
|
static Money |
of(CurrencyEnum currencyEnum,
long number) |
static Money |
of(Currency currency,
long number) |
static Money |
of(String currencyCode,
long number) |
static Money |
ofMajor(Currency currency,
BigDecimal majorUnitNumber,
RoundingMode roundingMode)
Creates a new Money instance with the specified currency, major number and rounding mode.
|
static Money |
ofMajor(CurrencyEnum currencyEnum,
BigDecimal majorUnitNumber,
RoundingMode roundingMode) |
Money |
ofMajor(CurrencyEnum currencyEnum,
String majorUnitNumber,
RoundingMode roundingMode) |
Money |
ofMajor(Currency currency,
String majorUnitNumber,
RoundingMode roundingMode) |
static Money |
ofMajor(String currencyCode,
BigDecimal majorUnitNumber,
RoundingMode roundingMode) |
Money |
ofMajor(String currencyCode,
String majorUnitNumber,
RoundingMode roundingMode) |
void |
setNumber(long number)
Set number
|
Money[] |
slice(int segment)
Average slice this money to segment part
|
Money[] |
slice(long[] ratios)
Slice this money with specified ratios
|
Money |
subtract(Money other)
Returns new Money object of the two money subtraction
|
Money |
subtractFrom(Money other)
This money subtraction other money
|
BigDecimal |
toMajorNumber()
Returns BigDecimal of major number string
|
String |
toMajorString()
Returns major number string
|
String |
toString()
Returns the string representation of this Money.
|
static Money |
zero(Currency currency)
Obtains an instance of
Money representing zero at a specific currency. |
static Money |
zero(CurrencyEnum currencyEnum) |
static Money |
zero(String currencyCode) |
public Money(Currency currency, long majorUnitNumber, int minorUnitNumber)
currency - the currencymajorUnitNumber - the majorUnitNumberminorUnitNumber - the minorUnitNumberpublic Money(Currency currency, long number)
public static Money of(CurrencyEnum currencyEnum, long number)
public Money ofMajor(CurrencyEnum currencyEnum, String majorUnitNumber, RoundingMode roundingMode)
public Money ofMajor(String currencyCode, String majorUnitNumber, RoundingMode roundingMode)
public Money ofMajor(Currency currency, String majorUnitNumber, RoundingMode roundingMode)
public static Money ofMajor(CurrencyEnum currencyEnum, BigDecimal majorUnitNumber, RoundingMode roundingMode)
public static Money ofMajor(String currencyCode, BigDecimal majorUnitNumber, RoundingMode roundingMode)
public static Money ofMajor(Currency currency, BigDecimal majorUnitNumber, RoundingMode roundingMode)
currency - the currencymajorUnitNumber - the major unit numberroundingMode - the rounding modepublic static Money zero(Currency currency)
Money representing zero at a specific currency.
For example, zero(USD) creates the instance USD 0.00.
currency - the currency, not nullpublic static Money zero(CurrencyEnum currencyEnum)
public Currency getCurrency()
java.util.Currency objectpublic long getNumber()
public final String getCurrencyCode()
public void setNumber(long number)
number - the numberpublic final int getFactor()
public BigDecimal toMajorNumber()
public String toMajorString()
public boolean equals(Object other)
equals 在类中 Objectother - the other objecttrue if equalsObject.equals(java.lang.Object)public boolean equals(Money other)
other - the other moneytrue if equalspublic int hashCode()
hashCode 在类中 ObjectObject.hashCode()public Money clone()
clone 在类中 ObjectObject.clone()public String toString()
public int compareTo(Money other)
compareTo 在接口中 Comparable<Money>other - the other money.public boolean greaterThan(Money other)
other - the other money.true if greater than otherpublic Money add(Money other)
other - the other money.public Money addTo(Money other)
other - the other moneypublic Money subtract(Money other)
other - the other money.public Money subtractFrom(Money other)
other - the other moneypublic Money multiply(long val)
val - the valuepublic Money multiplyBy(long val)
val - the valuepublic Money multiply(BigDecimal val)
val - the valuepublic Money multiplyBy(BigDecimal val)
val - the valuepublic Money multiply(BigDecimal val, RoundingMode roundingMode)
val - the valueroundingMode - the rounding modepublic Money multiplyBy(BigDecimal val, RoundingMode roundingMode)
val - the valueroundingMode - the rounding modepublic Money divide(BigDecimal val)
public Money divide(BigDecimal val, RoundingMode roundingMode)
public Money divideBy(BigDecimal val)
public Money divideBy(BigDecimal val, RoundingMode roundingMode)
public Money[] slice(int segment)
segment - the segmentpublic Money[] slice(long[] ratios)
ratios - the ratioCopyright © 2023. All rights reserved.