]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/samples/numfmt/main.cpp
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / samples / numfmt / main.cpp
index 1ebd4948c37c90349b87ff26a521084646d238af..5adffe3643e58f166de096d16ae5a19a6fac20f3 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1999-2004, International Business Machines Corporation and
+ * Copyright (c) 1999-2010, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -113,7 +113,8 @@ setNumberFormatCurrency_2_4(NumberFormat &nf, const char *currency, UErrorCode &
     // check that the formatter is a DecimalFormat instance
     // necessary because we will cast to the DecimalFormat subclass to set
     // the currency symbol
-    if(nf.getDynamicClassID()!=DecimalFormat::getStaticClassID()) {
+    DecimalFormat *dnf=dynamic_cast<DecimalFormat *>(&nf);
+    if(dnf==NULL) {
         errorCode=U_ILLEGAL_ARGUMENT_ERROR;
         return;
     }
@@ -168,12 +169,11 @@ setNumberFormatCurrency_2_4(NumberFormat &nf, const char *currency, UErrorCode &
     nf.setMinimumFractionDigits(currencyMap[i].fractionDigits);
     nf.setMaximumFractionDigits(currencyMap[i].fractionDigits);
 
-    DecimalFormat &dnf=(DecimalFormat &)nf;
-    dnf.setRoundingIncrement(currencyMap[i].roundingIncrement);
+    dnf->setRoundingIncrement(currencyMap[i].roundingIncrement);
 
-    DecimalFormatSymbols symbols(*dnf.getDecimalFormatSymbols());
+    DecimalFormatSymbols symbols(*dnf->getDecimalFormatSymbols());
     symbols.setSymbol(DecimalFormatSymbols::kCurrencySymbol, currencyMap[i].symbol);
-    dnf.setDecimalFormatSymbols(symbols); // do not adopt symbols: Jitterbug 2889
+    dnf->setDecimalFormatSymbols(symbols); // do not adopt symbols: Jitterbug 2889
 }
 
 /*