src/share/classes/java/text/DecimalFormat.java

Print this page




 354  *         case 0:
 355  *             form = NumberFormat.getInstance(locales[i]); break;
 356  *         case 1:
 357  *             form = NumberFormat.getIntegerInstance(locales[i]); break;
 358  *         case 2:
 359  *             form = NumberFormat.getCurrencyInstance(locales[i]); break;
 360  *         default:
 361  *             form = NumberFormat.getPercentInstance(locales[i]); break;
 362  *         }
 363  *         if (form instanceof DecimalFormat) {
 364  *             System.out.print(": " + ((DecimalFormat) form).toPattern());
 365  *         }
 366  *         System.out.print(" -> " + form.format(myNumber));
 367  *         try {
 368  *             System.out.println(" -> " + form.parse(form.format(myNumber)));
 369  *         } catch (ParseException e) {}
 370  *     }
 371  * }
 372  * }</pre></blockquote>
 373  *
 374  * @see          <a href="http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html">Java Tutorial</a>
 375  * @see          NumberFormat
 376  * @see          DecimalFormatSymbols
 377  * @see          ParsePosition
 378  * @author       Mark Davis
 379  * @author       Alan Liu
 380  */
 381 public class DecimalFormat extends NumberFormat {
 382 
 383     /**
 384      * Creates a DecimalFormat using the default pattern and symbols
 385      * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
 386      * This is a convenient way to obtain a
 387      * DecimalFormat when internationalization is not the main concern.
 388      * <p>
 389      * To obtain standard formats for a given locale, use the factory methods
 390      * on NumberFormat such as getNumberInstance. These factories will
 391      * return the most appropriate sub-class of NumberFormat for a given
 392      * locale.
 393      *
 394      * @see java.text.NumberFormat#getInstance




 354  *         case 0:
 355  *             form = NumberFormat.getInstance(locales[i]); break;
 356  *         case 1:
 357  *             form = NumberFormat.getIntegerInstance(locales[i]); break;
 358  *         case 2:
 359  *             form = NumberFormat.getCurrencyInstance(locales[i]); break;
 360  *         default:
 361  *             form = NumberFormat.getPercentInstance(locales[i]); break;
 362  *         }
 363  *         if (form instanceof DecimalFormat) {
 364  *             System.out.print(": " + ((DecimalFormat) form).toPattern());
 365  *         }
 366  *         System.out.print(" -> " + form.format(myNumber));
 367  *         try {
 368  *             System.out.println(" -> " + form.parse(form.format(myNumber)));
 369  *         } catch (ParseException e) {}
 370  *     }
 371  * }
 372  * }</pre></blockquote>
 373  *
 374  * @see          <a href="http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html">Java Tutorial</a>
 375  * @see          NumberFormat
 376  * @see          DecimalFormatSymbols
 377  * @see          ParsePosition
 378  * @author       Mark Davis
 379  * @author       Alan Liu
 380  */
 381 public class DecimalFormat extends NumberFormat {
 382 
 383     /**
 384      * Creates a DecimalFormat using the default pattern and symbols
 385      * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
 386      * This is a convenient way to obtain a
 387      * DecimalFormat when internationalization is not the main concern.
 388      * <p>
 389      * To obtain standard formats for a given locale, use the factory methods
 390      * on NumberFormat such as getNumberInstance. These factories will
 391      * return the most appropriate sub-class of NumberFormat for a given
 392      * locale.
 393      *
 394      * @see java.text.NumberFormat#getInstance