-
Enhancement
-
Resolution: Fixed
-
P5
-
1.4.1
-
b16
-
x86
-
windows_2000
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2152894 | OpenJDK6 | Naoto Sato | P2 | Resolved | Fixed | b02 |
Name: rmT116609 Date: 03/24/2003
A DESCRIPTION OF THE REQUEST :
ISO 4217, the standard on which this class is based, defines two currency codes -- one alphabetic and one numeric. The current version of the class implements only the alphabetic code and not the numeric. For instance:
Currency curr = Currency.getInstance("USD");
System.out.println( "Currency Code = " + curr.getCurrencyCode() );
will print out:
Currency Code = USD
There is no method which will return the currency number. I suggest a method such as
public int getCurrencyNumber(){}
In this way the currency number can be returned.
JUSTIFICATION :
1) The current class does not fully implement the ISO standard.
2) The numeric representation of the currency is used by banking facilities worldwide.
3) It is more efficient to use the numeric representation in comparisons.
4) The numeric representation of the currency may be used in "switch" constructs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Currency curr = Currency.getInstance("USD");
System.out.println( "Currency Code = " + curr.getCurrencyCode() );
System.out.println( "Currency Number = " + String.valueOf(curr.getCurrencyNumber()) );
results in
Currency Code = USD
Currency Number = 840
Not implemented.
---------- BEGIN SOURCE ----------
public class TestCurrency
{
public static void main( String args[] )
{
Currency curr = Currency.getInstance("USD");
System.out.println( "Currency Code = " + curr.getCurrencyCode() );
System.out.println( "Currency Number = " + String.valueOf(curr.getCurrencyNumber()) );
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
package Test;
import java.util.Locale;
public class Currency
{
//Global constants
//Global variables
//Instance constants
//Instance variables
java.util.Currency curr = null;
//Constructors
public Currency( String currCode )
{
curr = java.util.Currency.getInstance(currCode);
}
public Currency( Locale currLocale )
{
curr = java.util.Currency.getInstance(currLocale);
}
//Methods
public String getCurrencyCode()
{
return( curr.getCurrencyCode() );
}
public int getCurrencyNumber()
{
String cCode = this.getCurrencyCode();
if( cCode.equals("USD") ) return(840);
return(0);
}
public static void main( String args[] )
{
try
{
Test.Currency curr = new Test.Currency("USD");
int cCode = curr.getCurrencyNumber();
System.out.println( String.valueOf(cCode) );
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
when runs, results in:
840
which is the numeric representation of the currency "USD".
(Review ID: 182955)
======================================================================
A DESCRIPTION OF THE REQUEST :
ISO 4217, the standard on which this class is based, defines two currency codes -- one alphabetic and one numeric. The current version of the class implements only the alphabetic code and not the numeric. For instance:
Currency curr = Currency.getInstance("USD");
System.out.println( "Currency Code = " + curr.getCurrencyCode() );
will print out:
Currency Code = USD
There is no method which will return the currency number. I suggest a method such as
public int getCurrencyNumber(){}
In this way the currency number can be returned.
JUSTIFICATION :
1) The current class does not fully implement the ISO standard.
2) The numeric representation of the currency is used by banking facilities worldwide.
3) It is more efficient to use the numeric representation in comparisons.
4) The numeric representation of the currency may be used in "switch" constructs.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Currency curr = Currency.getInstance("USD");
System.out.println( "Currency Code = " + curr.getCurrencyCode() );
System.out.println( "Currency Number = " + String.valueOf(curr.getCurrencyNumber()) );
results in
Currency Code = USD
Currency Number = 840
Not implemented.
---------- BEGIN SOURCE ----------
public class TestCurrency
{
public static void main( String args[] )
{
Currency curr = Currency.getInstance("USD");
System.out.println( "Currency Code = " + curr.getCurrencyCode() );
System.out.println( "Currency Number = " + String.valueOf(curr.getCurrencyNumber()) );
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
package Test;
import java.util.Locale;
public class Currency
{
//Global constants
//Global variables
//Instance constants
//Instance variables
java.util.Currency curr = null;
//Constructors
public Currency( String currCode )
{
curr = java.util.Currency.getInstance(currCode);
}
public Currency( Locale currLocale )
{
curr = java.util.Currency.getInstance(currLocale);
}
//Methods
public String getCurrencyCode()
{
return( curr.getCurrencyCode() );
}
public int getCurrencyNumber()
{
String cCode = this.getCurrencyCode();
if( cCode.equals("USD") ) return(840);
return(0);
}
public static void main( String args[] )
{
try
{
Test.Currency curr = new Test.Currency("USD");
int cCode = curr.getCurrencyNumber();
System.out.println( String.valueOf(cCode) );
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
when runs, results in:
840
which is the numeric representation of the currency "USD".
(Review ID: 182955)
======================================================================
- backported by
-
JDK-2152894 RFE: Add Currency Number to java.util.Currency
-
- Resolved
-
- relates to
-
JDK-4879780 RFE: improve iso support in java (ISO-4217, ISO-3166)
-
- Closed
-
-
JDK-6332666 RFE: Better Currency Data support
-
- Closed
-
-
JDK-8252497 Incorrect numeric currency code for ROL
-
- Closed
-