Class ISOCurrency

java.lang.Object
org.jpos.iso.ISOCurrency

public class ISOCurrency extends Object
ISO Currency Conversion package
See Also:
  • Method Details

    • loadPropertiesFromClasspath

      public static void loadPropertiesFromClasspath(String base)
      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 doubles
      Converts 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

      public static String toISO87String(BigDecimal amount, String currency)
      Converts a BigDecimal amount to an ISO 8583 amount string.
      Parameters:
      amount - the monetary amount
      currency - the ISO 4217 currency code
      Returns:
      the formatted ISO 87 string
    • parseFromISO87String

      public static BigDecimal parseFromISO87String(String isoamount, String currency)
      Parses an ISO 8583 amount string to a BigDecimal.
      Parameters:
      isoamount - the ISO 87 amount string
      currency - the ISO 4217 currency code
      Returns:
      the parsed BigDecimal amount
    • addBundle

      public static void addBundle(String bundleName)
      Adds a resource bundle for currency definitions.
      Parameters:
      bundleName - the bundle name to add
    • 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 converted
      currency - - 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

      public static Currency getCurrency(int code) throws ISOException
      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

      public static Currency getCurrency(String code) throws ISOException
      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