Class Money
A Money
instance represents a monetary amount together with a currency.
public class Money
extends Object
java.lang.Object ← io.justtrack.Money
Constructors
Money
public Money(double value, @NonNull String currency)
Create a new Money
instance with the given amount and currency.
Parameters
Name | Description |
---|---|
value | The monetary amount. Needs to be a finite value. |
currency | The currency for the amount. Needs to be an uppercase 3-letter ISO 4217 string. |
Methods
getCurrency
@NonNull
public String getCurrency()
Get the currency stored in this instance.
Returns
The currency value.
getValue
public double getValue()
Get the value stored in this instance.
Returns
The monetary value.
toString
public String toString()
Overrides
toString
in class Object
validate
public void validate() throws InvalidFieldException
Validate the information stored in this instance.
The monetary value must be a finite value (thus, neither NaN or ±Infinity). The currency code needs to be an uppercase 3-letter ISO 4217 string.
You don't need to call this method normally, it will automatically be called once you submit
a AppEvent
to JustTrackSdk.publishEvent(AppEvent)
.
Throws
Name | Description |
---|---|
InvalidFieldException | If any field has an invalid value. |