From c618b5f802523d960e789478577b1bb61b9748f5 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 19 Nov 2003 12:06:38 +0000 Subject: [multiple changes] 2003-11-19 Guilhem Lavaux Jim Pick * java/text/DecimalFormat.java (getCurrency, setCurrency): New methods. 2003-11-19 Guilhem Lavaux * java/text/DecimalFormatSymbols.java (getCurrency, setCurrency): New methods. Co-Authored-By: Jim Pick From-SVN: r73735 --- libjava/ChangeLog | 11 +++++++++++ libjava/java/text/DecimalFormat.java | 24 ++++++++++++++++++++++++ libjava/java/text/DecimalFormatSymbols.java | 23 +++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ef79f94..98cc75e 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,14 @@ +2003-11-19 Guilhem Lavaux + Jim Pick + + * java/text/DecimalFormat.java (getCurrency, setCurrency): New + methods. + +2003-11-19 Guilhem Lavaux + + * java/text/DecimalFormatSymbols.java (getCurrency, + setCurrency): New methods. + 2003-11-19 Sascha Brawer * java/awt/geom/FlatteningPathIterator.java: Entirely re-written. diff --git a/libjava/java/text/DecimalFormat.java b/libjava/java/text/DecimalFormat.java index 8dae187..359ad55 100644 --- a/libjava/java/text/DecimalFormat.java +++ b/libjava/java/text/DecimalFormat.java @@ -37,6 +37,7 @@ exception statement from your version. */ package java.text; +import java.util.Currency; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -637,6 +638,19 @@ public class DecimalFormat extends NumberFormat return dest; } + /** + * Returns the currency corresponding to the currency symbol stored + * in the instance of DecimalFormatSymbols used by this + * DecimalFormat. + * + * @return A new instance of Currency if + * the currency code matches a known one, null otherwise. + */ + public Currency getCurrency() + { + return symbols.getCurrency(); + } + public DecimalFormatSymbols getDecimalFormatSymbols () { return symbols; @@ -856,6 +870,16 @@ public class DecimalFormat extends NumberFormat return result; } + /** + * Sets the Currency on the + * DecimalFormatSymbols used, which also sets the + * currency symbols on those symbols. + */ + public void setCurrency(Currency currency) + { + symbols.setCurrency(currency); + } + public void setDecimalFormatSymbols (DecimalFormatSymbols newSymbols) { symbols = newSymbols; diff --git a/libjava/java/text/DecimalFormatSymbols.java b/libjava/java/text/DecimalFormatSymbols.java index 2c1d971..1cb8f4f 100644 --- a/libjava/java/text/DecimalFormatSymbols.java +++ b/libjava/java/text/DecimalFormatSymbols.java @@ -39,6 +39,7 @@ exception statement from your version. */ package java.text; import java.io.Serializable; +import java.util.Currency; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -195,6 +196,18 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable } /** + * Returns the currency corresponding to the currency symbol stored + * in the instance of DecimalFormatSymbols. + * + * @return A new instance of Currency if + * the currency code matches a known one. + */ + public Currency getCurrency () + { + return Currency.getInstance (currencySymbol); + } + + /** * This method returns the currency symbol in local format. For example, * "$" for Canadian dollars. * @@ -354,6 +367,16 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable } /** + * This method sets the currency to the specified value. + * + * @param currency The new currency + */ + public void setCurrency (Currency currency) + { + setCurrencySymbol (currency.getSymbol()); + } + + /** * This method sets the currency symbol to the specified value. * * @param currencySymbol The new currency symbol -- cgit v1.1