Class CurrencyUtil
java.lang.Object
com.infinitekind.moneydance.model.CurrencyUtil
public abstract class CurrencyUtil
extends java.lang.Object
Miscellaneous currency functions (mostly conversion).
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<CurrencyType>
CURRENCY_NAME_COMPARATOR
static java.util.Comparator<CurrencyType>
CURRENCY_TYPENAME_COMPARATOR
-
Constructor Summary
Constructors Constructor Description CurrencyUtil()
-
Method Summary
Modifier and Type Method Description static double
convertToBasePrice(double priceFromCurr, CurrencyType curr, int date)
Convert the given price (in terms of the given currency) to a price in terms of the base currency.static long
convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency)
Return the amount of toCurrency that the given value of fromCurrency is currently worth.static long
convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency, double userRate)
Return the amount of 'toCurrency' obtained by exchanging 'value' of 'fromCurrency' at the rate 'rate'static long
convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)
Return the amount of toCurrency that the given value of fromCurrency was worth on the given date.static CurrencyTable
createDefaultTable(AccountBook book, java.lang.String primaryCurrency)
static double
getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency)
Get the raw (adjusted for decimal place differences) rate between the two currencies.static double
getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency, double userRate)
Convert the given user-identifiable rate to the 'raw' rate used to exchange amounts between the given two currencies.static double
getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)
Get the raw (adjusted for decimal place differences) rate between the two currencies.static double
getSplitAdjustedRelativeUserPrice(CurrencyType curr1, CurrencyType curr2, int date)
Get the price (going rate) for currency curr1 in terms of curr2 on the given date.static double
getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency)
Get the current user-identifiable rate from fromCurrency to toCurrency.static double
getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency, double rawRate)
Convert the given raw rate to the user-identifiable rate used to exchange amounts between the given two currencies.static double
getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)
Get the raw (adjusted for decimal place differences) rate between the two currencies.static void
main(java.lang.String[] argv)
static long
parseCurrencyExpression(java.lang.String str, char dec, CurrencyType toCurr, CurrencyTable currTable)
static long
parseCurrencyExpression(java.lang.String str, char dec, CurrencyType toCurr, CurrencyTable currTable, boolean insertDecimal)
-
Field Details
-
Constructor Details
-
CurrencyUtil
public CurrencyUtil()
-
-
Method Details
-
getRawRate
public static double getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)Get the raw (adjusted for decimal place differences) rate between the two currencies. The rate that is used is the one effective on the given date. -
getUserRate
public static double getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)Get the raw (adjusted for decimal place differences) rate between the two currencies. The rate that is used is the one effective on the given date. -
getRawRate
Get the raw (adjusted for decimal place differences) rate between the two currencies. -
convertToBasePrice
Convert the given price (in terms of the given currency) to a price in terms of the base currency. -
getRawRate
public static double getRawRate(CurrencyType fromCurrency, CurrencyType toCurrency, double userRate)Convert the given user-identifiable rate to the 'raw' rate used to exchange amounts between the given two currencies. -
getUserRate
public static double getUserRate(CurrencyType fromCurrency, CurrencyType toCurrency, double rawRate)Convert the given raw rate to the user-identifiable rate used to exchange amounts between the given two currencies. -
getUserRate
Get the current user-identifiable rate from fromCurrency to toCurrency. -
convertValue
Return the amount of toCurrency that the given value of fromCurrency is currently worth. -
convertValue
public static long convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency, double userRate)Return the amount of 'toCurrency' obtained by exchanging 'value' of 'fromCurrency' at the rate 'rate' -
convertValue
public static long convertValue(long value, CurrencyType fromCurrency, CurrencyType toCurrency, int effectiveDate)Return the amount of toCurrency that the given value of fromCurrency was worth on the given date. -
getSplitAdjustedRelativeUserPrice
public static double getSplitAdjustedRelativeUserPrice(CurrencyType curr1, CurrencyType curr2, int date)Get the price (going rate) for currency curr1 in terms of curr2 on the given date. This adjusts the price to be in terms of splits in either currency so that the price is in terms of today's units of each currency (but the price is from the given date, not today's prices). -
parseCurrencyExpression
public static final long parseCurrencyExpression(java.lang.String str, char dec, CurrencyType toCurr, CurrencyTable currTable) throws java.lang.Exception- Throws:
java.lang.Exception
-
parseCurrencyExpression
public static final long parseCurrencyExpression(java.lang.String str, char dec, CurrencyType toCurr, CurrencyTable currTable, boolean insertDecimal) throws java.lang.Exception- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
createDefaultTable
-