-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
6
-
x86
-
windows_xp
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.
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.