--- old/src/java.base/share/classes/java/util/Currency.java 2016-05-02 10:59:39.893680000 +0530 +++ new/src/java.base/share/classes/java/util/Currency.java 2016-05-02 10:59:39.709588000 +0530 @@ -544,6 +544,29 @@ public int getNumericCode() { return numericCode; } + + /** + * Returns the 3 digit ISO 4217 numeric code of this currency as a {@code String}. + * Unlike {@link getNumericCode()}, which returns the numeric code as {@code int}, + * this method always returns the numeric code as a 3 digit string. + * e.g. a numeric value of 32 would be returned as "032", + * and a numeric value of 6 would be returned as "006". + * + * @return the 3 digit ISO 4217 numeric code of this currency as a {@code String} + * @since 9 + */ + public String getNumericCodeAsString() + { + if (numericCode < 100) { + StringBuilder sb = new StringBuilder(); + sb.append('0'); + if (numericCode < 10) { + sb.append('0'); + } + return sb.append(numericCode).toString(); + } + return String.valueOf(numericCode); + } /** * Gets the name that is suitable for displaying this currency for @@ -788,3 +811,4 @@ } } } +