public class Amount extends java.lang.Object implements java.io.Serializable
A number of monetary units specified by a currency where the currency is explicit or implied.
Constructor and Description |
---|
Amount(java.math.BigDecimal value,
com.neovisionaries.i18n.CurrencyCode currency)
Instantiates a new amount.
|
Amount(long value,
com.neovisionaries.i18n.CurrencyCode currency)
Instantiates a new amount.
|
Amount(java.lang.String value,
com.neovisionaries.i18n.CurrencyCode currency)
Instantiates a new amount.
|
Modifier and Type | Method and Description |
---|---|
com.neovisionaries.i18n.CurrencyCode |
getCurrency()
Gets the currency code.
|
java.math.BigDecimal |
getValue()
Gets the amount value.
|
Amount |
setCurrency(com.neovisionaries.i18n.CurrencyCode currency)
Sets the currency code.
|
Amount |
setValue(java.math.BigDecimal value)
Sets the amount value.
|
java.lang.String |
toString() |
public Amount(java.math.BigDecimal value, com.neovisionaries.i18n.CurrencyCode currency)
Instantiates a new amount.
value
- the valuecurrency
- the currency codepublic Amount(long value, com.neovisionaries.i18n.CurrencyCode currency)
Instantiates a new amount.
value
- the monetary value as a longcurrency
- the currency codepublic Amount(java.lang.String value, com.neovisionaries.i18n.CurrencyCode currency)
Instantiates a new amount.
value
- the monetary value as a stringcurrency
- the currency codejava.lang.NumberFormatException
- if value is not a valid representation of a BigDecimal.public com.neovisionaries.i18n.CurrencyCode getCurrency()
Gets the currency code.
public java.math.BigDecimal getValue()
Gets the amount value.
public Amount setCurrency(com.neovisionaries.i18n.CurrencyCode currency)
Sets the currency code.
currency
- the new ISO 4217 3A currency codepublic Amount setValue(java.math.BigDecimal value)
Sets the amount value.
value
- the new valuepublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014-2018 Konik.io. All Rights Reserved.