Class ISOCurrency
java.lang.Object
org.jpos.iso.ISOCurrency
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a resource bundle for currency definitions.static doubleconvertFromIsoMsg(String isoamount, String currency) Deprecated.You should never use doublesstatic StringconvertToIsoMsg(double amount, String currency) Converts an amount to an ISO Amount taking in consideration the number of decimal digits according to currencystatic Object[]decomposeComposedCurrency(String incurr) Decomposes a composed currency string into its components.static CurrencygetCurrency(int code) Returns the Currency for the given numeric ISO 4217 code.static CurrencygetCurrency(String code) Returns the Currency for the given string code.static StringgetIsoCodeFromAlphaCode(String alphacode) Returns the ISO numeric code for the given alpha currency code.static voidLoads currency properties from the classpath.static BigDecimalparseFromISO87String(String isoamount, String currency) Parses an ISO 8583 amount string to a BigDecimal.static StringtoISO87String(BigDecimal amount, String currency) Converts a BigDecimal amount to an ISO 8583 amount string.
-
Method Details
-
loadPropertiesFromClasspath
Loads currency properties from the classpath.- Parameters:
base- base path for properties resource
-
convertFromIsoMsg
@Deprecated public static double convertFromIsoMsg(String isoamount, String currency) throws IllegalArgumentException Deprecated.You should never use doublesConverts from an ISO Amount (12 digit string) to a double taking in consideration the number of decimal digits according to currency- Parameters:
isoamount- - The ISO amount to be converted (eg. ISOField 4)currency- - The ISO currency to be converted (eg. ISOField 49)- Returns:
- result - A double representing the converted field
- Throws:
IllegalArgumentException- if we fail to convert the amount
-
toISO87String
Converts a BigDecimal amount to an ISO 8583 amount string.- Parameters:
amount- the monetary amountcurrency- the ISO 4217 currency code- Returns:
- the formatted ISO 87 string
-
parseFromISO87String
Parses an ISO 8583 amount string to a BigDecimal.- Parameters:
isoamount- the ISO 87 amount stringcurrency- the ISO 4217 currency code- Returns:
- the parsed BigDecimal amount
-
addBundle
-
convertToIsoMsg
public static String convertToIsoMsg(double amount, String currency) throws IllegalArgumentException Converts an amount to an ISO Amount taking in consideration the number of decimal digits according to currency- Parameters:
amount- - The amount to be convertedcurrency- - The ISO currency to be converted (eg. ISOField 49)- Returns:
- result - An iso amount representing the converted field
- Throws:
IllegalArgumentException- if we fail to convert the amount
-
decomposeComposedCurrency
Decomposes a composed currency string into its components.- Parameters:
incurr- the composed currency string- Returns:
- an Object array with the decomposed parts
- Throws:
IllegalArgumentException- if the currency is invalid
-
getIsoCodeFromAlphaCode
Returns the ISO numeric code for the given alpha currency code.- Parameters:
alphacode- the 3-letter alpha currency code- Returns:
- the ISO numeric code as a string
- Throws:
IllegalArgumentException- if the code is unknown
-
getCurrency
Returns the Currency for the given numeric ISO 4217 code.- Parameters:
code- the numeric currency code- Returns:
- the corresponding Currency
- Throws:
ISOException- if the code is unknown
-
getCurrency
Returns the Currency for the given string code.- Parameters:
code- the currency code (numeric or alpha)- Returns:
- the corresponding Currency
- Throws:
ISOException- if the code is unknown
-