Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6581443

RFE: Historical ISO 4217 currency code support

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Java throws an IllegalArgumentException for currency codes which it does not support. What is odd however is that it supports some obsolete ISO 4217 codes, but not others. We calculate historical performance of currencies based on their code, but we have to use our own Currency class because Java does not support all obsolete currencies, so we cannot create java.util.Currency objects from them. Souldn't Java support all historial ISO 4217 codes if it supports some of them?

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the class supplied to find out the codes that java does not support.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      That it supported all obsolete ISO 4217 codes.
      ACTUAL -
      Java knows 29 of 81 obsolete currency codes listed on Wikipedia: http://en.wikipedia.org/wiki/ISO_4217

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Test {

        public static void main(String[] args) {
          int notValid = 0;
          for (final String ccyCode : OBSOLETE) {
            if (!isValid(ccyCode)) {
              notValid++;
              System.out.println(ccyCode + " not valid");
            }
          }
          System.out.println("Java knows " + (OBSOLETE.length - notValid) + " of "
                + OBSOLETE.length + " obsolete currency codes");
        }

        private static final String[] OBSOLETE = {
              "ADP", "ADF", "ATS", "BEF", "DEM", "ESP", "FIM", "FRF", "GRD", "IEP",
              "ITL", "LUF", "MCF", "NLG", "PTE", "SIT", "XEU", "AFA", "ALK", "AON",
              "AOR", "ARM", "ARL", "ARP", "ARA", "AZM", "BEC", "BEL", "BGJ", "BGK",
              "BGL", "BOP", "BRB", "BRC", "CFP", "CNX", "CSJ", "CSK", "DDM", "ECS",
              "ECV", "EQE", "ESA", "ESB", "GNE", "GHC", "GWP", "ILP", "ILR", "ISJ",
              "LAJ", "MAF", "MGF", "MKN", "MVQ", "MXP", "MZM", "PEH", "PEI", "PLZ",
              "ROK", "ROL", "RUR", "SDD", "SRG", "SUR", "SVC", "TJR", "TPE", "TRL",
              "UAK", "UGW", "UYN", "VNC", "YDD", "YUD", "YUM", "ZAL", "ZRN", "ZRZ",
              "ZWC"
        };

        private static boolean isValid(String ccyCode) {
          try {
            Currency.getInstance(ccyCode);
          } catch (IllegalArgumentException e) {
            return false;
          }
          return true;
        }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      You need to re-implement the Currency class to support these currencies, which is a bit of a pain.

            naoto Naoto Sato
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: