jdk/src/share/classes/java/text/DecimalFormat.java
changeset 19054 a64012cb49d6
parent 16010 2727163b5df5
child 20455 f6f9a0c2796b
equal deleted inserted replaced
19053:69648476a89e 19054:a64012cb49d6
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    85  * <code>applyPattern()</code>, or indirectly using the API methods.  The
    85  * <code>applyPattern()</code>, or indirectly using the API methods.  The
    86  * symbols are stored in a <code>DecimalFormatSymbols</code> object.  When using
    86  * symbols are stored in a <code>DecimalFormatSymbols</code> object.  When using
    87  * the <code>NumberFormat</code> factory methods, the pattern and symbols are
    87  * the <code>NumberFormat</code> factory methods, the pattern and symbols are
    88  * read from localized <code>ResourceBundle</code>s.
    88  * read from localized <code>ResourceBundle</code>s.
    89  *
    89  *
    90  * <h4>Patterns</h4>
    90  * <h3>Patterns</h3>
    91  *
    91  *
    92  * <code>DecimalFormat</code> patterns have the following syntax:
    92  * <code>DecimalFormat</code> patterns have the following syntax:
    93  * <blockquote><pre>
    93  * <blockquote><pre>
    94  * <i>Pattern:</i>
    94  * <i>Pattern:</i>
    95  *         <i>PositivePattern</i>
    95  *         <i>PositivePattern</i>
   172  * are not localized.
   172  * are not localized.
   173  *
   173  *
   174  * <blockquote>
   174  * <blockquote>
   175  * <table border=0 cellspacing=3 cellpadding=0 summary="Chart showing symbol,
   175  * <table border=0 cellspacing=3 cellpadding=0 summary="Chart showing symbol,
   176  *  location, localized, and meaning.">
   176  *  location, localized, and meaning.">
   177  *     <tr bgcolor="#ccccff">
   177  *     <tr style="background-color: rgb(204, 204, 255);">
   178  *          <th align=left>Symbol
   178  *          <th align=left>Symbol
   179  *          <th align=left>Location
   179  *          <th align=left>Location
   180  *          <th align=left>Localized?
   180  *          <th align=left>Localized?
   181  *          <th align=left>Meaning
   181  *          <th align=left>Meaning
   182  *     <tr valign=top>
   182  *     <tr valign=top>
   183  *          <td><code>0</code>
   183  *          <td><code>0</code>
   184  *          <td>Number
   184  *          <td>Number
   185  *          <td>Yes
   185  *          <td>Yes
   186  *          <td>Digit
   186  *          <td>Digit
   187  *     <tr valign=top bgcolor="#eeeeff">
   187  *     <tr style="vertical-align: top; background-color: rgb(238, 238, 255);">
   188  *          <td><code>#</code>
   188  *          <td><code>#</code>
   189  *          <td>Number
   189  *          <td>Number
   190  *          <td>Yes
   190  *          <td>Yes
   191  *          <td>Digit, zero shows as absent
   191  *          <td>Digit, zero shows as absent
   192  *     <tr valign=top>
   192  *     <tr valign=top>
   193  *          <td><code>.</code>
   193  *          <td><code>.</code>
   194  *          <td>Number
   194  *          <td>Number
   195  *          <td>Yes
   195  *          <td>Yes
   196  *          <td>Decimal separator or monetary decimal separator
   196  *          <td>Decimal separator or monetary decimal separator
   197  *     <tr valign=top bgcolor="#eeeeff">
   197  *     <tr style="vertical-align: top; background-color: rgb(238, 238, 255);">
   198  *          <td><code>-</code>
   198  *          <td><code>-</code>
   199  *          <td>Number
   199  *          <td>Number
   200  *          <td>Yes
   200  *          <td>Yes
   201  *          <td>Minus sign
   201  *          <td>Minus sign
   202  *     <tr valign=top>
   202  *     <tr valign=top>
   203  *          <td><code>,</code>
   203  *          <td><code>,</code>
   204  *          <td>Number
   204  *          <td>Number
   205  *          <td>Yes
   205  *          <td>Yes
   206  *          <td>Grouping separator
   206  *          <td>Grouping separator
   207  *     <tr valign=top bgcolor="#eeeeff">
   207  *     <tr style="vertical-align: top; background-color: rgb(238, 238, 255);">
   208  *          <td><code>E</code>
   208  *          <td><code>E</code>
   209  *          <td>Number
   209  *          <td>Number
   210  *          <td>Yes
   210  *          <td>Yes
   211  *          <td>Separates mantissa and exponent in scientific notation.
   211  *          <td>Separates mantissa and exponent in scientific notation.
   212  *              <em>Need not be quoted in prefix or suffix.</em>
   212  *              <em>Need not be quoted in prefix or suffix.</em>
   213  *     <tr valign=top>
   213  *     <tr valign=top>
   214  *          <td><code>;</code>
   214  *          <td><code>;</code>
   215  *          <td>Subpattern boundary
   215  *          <td>Subpattern boundary
   216  *          <td>Yes
   216  *          <td>Yes
   217  *          <td>Separates positive and negative subpatterns
   217  *          <td>Separates positive and negative subpatterns
   218  *     <tr valign=top bgcolor="#eeeeff">
   218  *     <tr style="vertical-align: top; background-color: rgb(238, 238, 255);">
   219  *          <td><code>%</code>
   219  *          <td><code>%</code>
   220  *          <td>Prefix or suffix
   220  *          <td>Prefix or suffix
   221  *          <td>Yes
   221  *          <td>Yes
   222  *          <td>Multiply by 100 and show as percentage
   222  *          <td>Multiply by 100 and show as percentage
   223  *     <tr valign=top>
   223  *     <tr valign=top>
   224  *          <td><code>&#92;u2030</code>
   224  *          <td><code>&#92;u2030</code>
   225  *          <td>Prefix or suffix
   225  *          <td>Prefix or suffix
   226  *          <td>Yes
   226  *          <td>Yes
   227  *          <td>Multiply by 1000 and show as per mille value
   227  *          <td>Multiply by 1000 and show as per mille value
   228  *     <tr valign=top bgcolor="#eeeeff">
   228  *     <tr style="vertical-align: top; background-color: rgb(238, 238, 255);">
   229  *          <td><code>&#164;</code> (<code>&#92;u00A4</code>)
   229  *          <td><code>&#164;</code> (<code>&#92;u00A4</code>)
   230  *          <td>Prefix or suffix
   230  *          <td>Prefix or suffix
   231  *          <td>No
   231  *          <td>No
   232  *          <td>Currency sign, replaced by currency symbol.  If
   232  *          <td>Currency sign, replaced by currency symbol.  If
   233  *              doubled, replaced by international currency symbol.
   233  *              doubled, replaced by international currency symbol.
   246  *
   246  *
   247  * <h4>Scientific Notation</h4>
   247  * <h4>Scientific Notation</h4>
   248  *
   248  *
   249  * <p>Numbers in scientific notation are expressed as the product of a mantissa
   249  * <p>Numbers in scientific notation are expressed as the product of a mantissa
   250  * and a power of ten, for example, 1234 can be expressed as 1.234 x 10^3.  The
   250  * and a power of ten, for example, 1234 can be expressed as 1.234 x 10^3.  The
   251  * mantissa is often in the range 1.0 <= x < 10.0, but it need not be.
   251  * mantissa is often in the range 1.0 &le; x {@literal <} 10.0, but it need not
       
   252  * be.
   252  * <code>DecimalFormat</code> can be instructed to format and parse scientific
   253  * <code>DecimalFormat</code> can be instructed to format and parse scientific
   253  * notation <em>only via a pattern</em>; there is currently no factory method
   254  * notation <em>only via a pattern</em>; there is currently no factory method
   254  * that creates a scientific notation format.  In a pattern, the exponent
   255  * that creates a scientific notation format.  In a pattern, the exponent
   255  * character immediately followed by one or more digit characters indicates
   256  * character immediately followed by one or more digit characters indicates
   256  * scientific notation.  Example: <code>"0.###E0"</code> formats the number
   257  * scientific notation.  Example: <code>"0.###E0"</code> formats the number
   334  * If multiple threads access a format concurrently, it must be synchronized
   335  * If multiple threads access a format concurrently, it must be synchronized
   335  * externally.
   336  * externally.
   336  *
   337  *
   337  * <h4>Example</h4>
   338  * <h4>Example</h4>
   338  *
   339  *
   339  * <blockquote><pre>
   340  * <blockquote><pre>{@code
   340  * <strong>// Print out a number using the localized number, integer, currency,
   341  * <strong>// Print out a number using the localized number, integer, currency,
   341  * // and percent format for each locale</strong>
   342  * // and percent format for each locale</strong>
   342  * Locale[] locales = NumberFormat.getAvailableLocales();
   343  * Locale[] locales = NumberFormat.getAvailableLocales();
   343  * double myNumber = -1234.56;
   344  * double myNumber = -1234.56;
   344  * NumberFormat form;
   345  * NumberFormat form;
   345  * for (int j=0; j<4; ++j) {
   346  * for (int j = 0; j < 4; ++j) {
   346  *     System.out.println("FORMAT");
   347  *     System.out.println("FORMAT");
   347  *     for (int i = 0; i < locales.length; ++i) {
   348  *     for (int i = 0; i < locales.length; ++i) {
   348  *         if (locales[i].getCountry().length() == 0) {
   349  *         if (locales[i].getCountry().length() == 0) {
   349  *            continue; // Skip language-only locales
   350  *            continue; // Skip language-only locales
   350  *         }
   351  *         }
   366  *         try {
   367  *         try {
   367  *             System.out.println(" -> " + form.parse(form.format(myNumber)));
   368  *             System.out.println(" -> " + form.parse(form.format(myNumber)));
   368  *         } catch (ParseException e) {}
   369  *         } catch (ParseException e) {}
   369  *     }
   370  *     }
   370  * }
   371  * }
   371  * </pre></blockquote>
   372  * }</pre></blockquote>
   372  *
   373  *
   373  * @see          <a href="http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html">Java Tutorial</a>
   374  * @see          <a href="http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html">Java Tutorial</a>
   374  * @see          NumberFormat
   375  * @see          NumberFormat
   375  * @see          DecimalFormatSymbols
   376  * @see          DecimalFormatSymbols
   376  * @see          ParsePosition
   377  * @see          ParsePosition
   419      * To obtain standard formats for a given locale, use the factory methods
   420      * To obtain standard formats for a given locale, use the factory methods
   420      * on NumberFormat such as getNumberInstance. These factories will
   421      * on NumberFormat such as getNumberInstance. These factories will
   421      * return the most appropriate sub-class of NumberFormat for a given
   422      * return the most appropriate sub-class of NumberFormat for a given
   422      * locale.
   423      * locale.
   423      *
   424      *
   424      * @param pattern A non-localized pattern string.
   425      * @param pattern a non-localized pattern string.
   425      * @exception NullPointerException if <code>pattern</code> is null
   426      * @exception NullPointerException if <code>pattern</code> is null
   426      * @exception IllegalArgumentException if the given pattern is invalid.
   427      * @exception IllegalArgumentException if the given pattern is invalid.
   427      * @see java.text.NumberFormat#getInstance
   428      * @see java.text.NumberFormat#getInstance
   428      * @see java.text.NumberFormat#getNumberInstance
   429      * @see java.text.NumberFormat#getNumberInstance
   429      * @see java.text.NumberFormat#getCurrencyInstance
   430      * @see java.text.NumberFormat#getCurrencyInstance
  2380     }
  2381     }
  2381 
  2382 
  2382     /**
  2383     /**
  2383      * Get the positive prefix.
  2384      * Get the positive prefix.
  2384      * <P>Examples: +123, $123, sFr123
  2385      * <P>Examples: +123, $123, sFr123
       
  2386      *
       
  2387      * @return the positive prefix
  2385      */
  2388      */
  2386     public String getPositivePrefix () {
  2389     public String getPositivePrefix () {
  2387         return positivePrefix;
  2390         return positivePrefix;
  2388     }
  2391     }
  2389 
  2392 
  2390     /**
  2393     /**
  2391      * Set the positive prefix.
  2394      * Set the positive prefix.
  2392      * <P>Examples: +123, $123, sFr123
  2395      * <P>Examples: +123, $123, sFr123
       
  2396      *
       
  2397      * @param newValue the new positive prefix
  2393      */
  2398      */
  2394     public void setPositivePrefix (String newValue) {
  2399     public void setPositivePrefix (String newValue) {
  2395         positivePrefix = newValue;
  2400         positivePrefix = newValue;
  2396         posPrefixPattern = null;
  2401         posPrefixPattern = null;
  2397         positivePrefixFieldPositions = null;
  2402         positivePrefixFieldPositions = null;
  2418     }
  2423     }
  2419 
  2424 
  2420     /**
  2425     /**
  2421      * Get the negative prefix.
  2426      * Get the negative prefix.
  2422      * <P>Examples: -123, ($123) (with negative suffix), sFr-123
  2427      * <P>Examples: -123, ($123) (with negative suffix), sFr-123
       
  2428      *
       
  2429      * @return the negative prefix
  2423      */
  2430      */
  2424     public String getNegativePrefix () {
  2431     public String getNegativePrefix () {
  2425         return negativePrefix;
  2432         return negativePrefix;
  2426     }
  2433     }
  2427 
  2434 
  2428     /**
  2435     /**
  2429      * Set the negative prefix.
  2436      * Set the negative prefix.
  2430      * <P>Examples: -123, ($123) (with negative suffix), sFr-123
  2437      * <P>Examples: -123, ($123) (with negative suffix), sFr-123
       
  2438      *
       
  2439      * @param newValue the new negative prefix
  2431      */
  2440      */
  2432     public void setNegativePrefix (String newValue) {
  2441     public void setNegativePrefix (String newValue) {
  2433         negativePrefix = newValue;
  2442         negativePrefix = newValue;
  2434         negPrefixPattern = null;
  2443         negPrefixPattern = null;
  2435         fastPathCheckNeeded = true;
  2444         fastPathCheckNeeded = true;
  2455     }
  2464     }
  2456 
  2465 
  2457     /**
  2466     /**
  2458      * Get the positive suffix.
  2467      * Get the positive suffix.
  2459      * <P>Example: 123%
  2468      * <P>Example: 123%
       
  2469      *
       
  2470      * @return the positive suffix
  2460      */
  2471      */
  2461     public String getPositiveSuffix () {
  2472     public String getPositiveSuffix () {
  2462         return positiveSuffix;
  2473         return positiveSuffix;
  2463     }
  2474     }
  2464 
  2475 
  2465     /**
  2476     /**
  2466      * Set the positive suffix.
  2477      * Set the positive suffix.
  2467      * <P>Example: 123%
  2478      * <P>Example: 123%
       
  2479      *
       
  2480      * @param newValue the new positive suffix
  2468      */
  2481      */
  2469     public void setPositiveSuffix (String newValue) {
  2482     public void setPositiveSuffix (String newValue) {
  2470         positiveSuffix = newValue;
  2483         positiveSuffix = newValue;
  2471         posSuffixPattern = null;
  2484         posSuffixPattern = null;
  2472         fastPathCheckNeeded = true;
  2485         fastPathCheckNeeded = true;
  2492     }
  2505     }
  2493 
  2506 
  2494     /**
  2507     /**
  2495      * Get the negative suffix.
  2508      * Get the negative suffix.
  2496      * <P>Examples: -123%, ($123) (with positive suffixes)
  2509      * <P>Examples: -123%, ($123) (with positive suffixes)
       
  2510      *
       
  2511      * @return the negative suffix
  2497      */
  2512      */
  2498     public String getNegativeSuffix () {
  2513     public String getNegativeSuffix () {
  2499         return negativeSuffix;
  2514         return negativeSuffix;
  2500     }
  2515     }
  2501 
  2516 
  2502     /**
  2517     /**
  2503      * Set the negative suffix.
  2518      * Set the negative suffix.
  2504      * <P>Examples: 123%
  2519      * <P>Examples: 123%
       
  2520      *
       
  2521      * @param newValue the new negative suffix
  2505      */
  2522      */
  2506     public void setNegativeSuffix (String newValue) {
  2523     public void setNegativeSuffix (String newValue) {
  2507         negativeSuffix = newValue;
  2524         negativeSuffix = newValue;
  2508         negSuffixPattern = null;
  2525         negSuffixPattern = null;
  2509         fastPathCheckNeeded = true;
  2526         fastPathCheckNeeded = true;
  2530 
  2547 
  2531     /**
  2548     /**
  2532      * Gets the multiplier for use in percent, per mille, and similar
  2549      * Gets the multiplier for use in percent, per mille, and similar
  2533      * formats.
  2550      * formats.
  2534      *
  2551      *
       
  2552      * @return the multiplier
  2535      * @see #setMultiplier(int)
  2553      * @see #setMultiplier(int)
  2536      */
  2554      */
  2537     public int getMultiplier () {
  2555     public int getMultiplier () {
  2538         return multiplier;
  2556         return multiplier;
  2539     }
  2557     }
  2547      * have '&#92;u2030'.
  2565      * have '&#92;u2030'.
  2548      *
  2566      *
  2549      * <P>Example: with multiplier 100, 1.23 is formatted as "123", and
  2567      * <P>Example: with multiplier 100, 1.23 is formatted as "123", and
  2550      * "123" is parsed into 1.23.
  2568      * "123" is parsed into 1.23.
  2551      *
  2569      *
       
  2570      * @param newValue the new multiplier
  2552      * @see #getMultiplier
  2571      * @see #getMultiplier
  2553      */
  2572      */
  2554     public void setMultiplier (int newValue) {
  2573     public void setMultiplier (int newValue) {
  2555         multiplier = newValue;
  2574         multiplier = newValue;
  2556         bigDecimalMultiplier = null;
  2575         bigDecimalMultiplier = null;
  2569 
  2588 
  2570     /**
  2589     /**
  2571      * Return the grouping size. Grouping size is the number of digits between
  2590      * Return the grouping size. Grouping size is the number of digits between
  2572      * grouping separators in the integer portion of a number.  For example,
  2591      * grouping separators in the integer portion of a number.  For example,
  2573      * in the number "123,456.78", the grouping size is 3.
  2592      * in the number "123,456.78", the grouping size is 3.
       
  2593      *
       
  2594      * @return the grouping size
  2574      * @see #setGroupingSize
  2595      * @see #setGroupingSize
  2575      * @see java.text.NumberFormat#isGroupingUsed
  2596      * @see java.text.NumberFormat#isGroupingUsed
  2576      * @see java.text.DecimalFormatSymbols#getGroupingSeparator
  2597      * @see java.text.DecimalFormatSymbols#getGroupingSeparator
  2577      */
  2598      */
  2578     public int getGroupingSize () {
  2599     public int getGroupingSize () {
  2583      * Set the grouping size. Grouping size is the number of digits between
  2604      * Set the grouping size. Grouping size is the number of digits between
  2584      * grouping separators in the integer portion of a number.  For example,
  2605      * grouping separators in the integer portion of a number.  For example,
  2585      * in the number "123,456.78", the grouping size is 3.
  2606      * in the number "123,456.78", the grouping size is 3.
  2586      * <br>
  2607      * <br>
  2587      * The value passed in is converted to a byte, which may lose information.
  2608      * The value passed in is converted to a byte, which may lose information.
       
  2609      *
       
  2610      * @param newValue the new grouping size
  2588      * @see #getGroupingSize
  2611      * @see #getGroupingSize
  2589      * @see java.text.NumberFormat#setGroupingUsed
  2612      * @see java.text.NumberFormat#setGroupingUsed
  2590      * @see java.text.DecimalFormatSymbols#setGroupingSeparator
  2613      * @see java.text.DecimalFormatSymbols#setGroupingSeparator
  2591      */
  2614      */
  2592     public void setGroupingSize (int newValue) {
  2615     public void setGroupingSize (int newValue) {
  2595     }
  2618     }
  2596 
  2619 
  2597     /**
  2620     /**
  2598      * Allows you to get the behavior of the decimal separator with integers.
  2621      * Allows you to get the behavior of the decimal separator with integers.
  2599      * (The decimal separator will always appear with decimals.)
  2622      * (The decimal separator will always appear with decimals.)
  2600      * <P>Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
  2623      * <P>Example: Decimal ON: 12345 &rarr; 12345.; OFF: 12345 &rarr; 12345
       
  2624      *
       
  2625      * @return {@code true} if the decimal separator is always shown;
       
  2626      *         {@code false} otherwise
  2601      */
  2627      */
  2602     public boolean isDecimalSeparatorAlwaysShown() {
  2628     public boolean isDecimalSeparatorAlwaysShown() {
  2603         return decimalSeparatorAlwaysShown;
  2629         return decimalSeparatorAlwaysShown;
  2604     }
  2630     }
  2605 
  2631 
  2606     /**
  2632     /**
  2607      * Allows you to set the behavior of the decimal separator with integers.
  2633      * Allows you to set the behavior of the decimal separator with integers.
  2608      * (The decimal separator will always appear with decimals.)
  2634      * (The decimal separator will always appear with decimals.)
  2609      * <P>Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345
  2635      * <P>Example: Decimal ON: 12345 &rarr; 12345.; OFF: 12345 &rarr; 12345
       
  2636      *
       
  2637      * @param newValue {@code true} if the decimal separator is always shown;
       
  2638      *                 {@code false} otherwise
  2610      */
  2639      */
  2611     public void setDecimalSeparatorAlwaysShown(boolean newValue) {
  2640     public void setDecimalSeparatorAlwaysShown(boolean newValue) {
  2612         decimalSeparatorAlwaysShown = newValue;
  2641         decimalSeparatorAlwaysShown = newValue;
  2613         fastPathCheckNeeded = true;
  2642         fastPathCheckNeeded = true;
  2614     }
  2643     }
  2615 
  2644 
  2616     /**
  2645     /**
  2617      * Returns whether the {@link #parse(java.lang.String, java.text.ParsePosition)}
  2646      * Returns whether the {@link #parse(java.lang.String, java.text.ParsePosition)}
  2618      * method returns <code>BigDecimal</code>. The default value is false.
  2647      * method returns <code>BigDecimal</code>. The default value is false.
       
  2648      *
       
  2649      * @return {@code true} if the parse method returns BigDecimal;
       
  2650      *         {@code false} otherwise
  2619      * @see #setParseBigDecimal
  2651      * @see #setParseBigDecimal
  2620      * @since 1.5
  2652      * @since 1.5
  2621      */
  2653      */
  2622     public boolean isParseBigDecimal() {
  2654     public boolean isParseBigDecimal() {
  2623         return parseBigDecimal;
  2655         return parseBigDecimal;
  2624     }
  2656     }
  2625 
  2657 
  2626     /**
  2658     /**
  2627      * Sets whether the {@link #parse(java.lang.String, java.text.ParsePosition)}
  2659      * Sets whether the {@link #parse(java.lang.String, java.text.ParsePosition)}
  2628      * method returns <code>BigDecimal</code>.
  2660      * method returns <code>BigDecimal</code>.
       
  2661      *
       
  2662      * @param newValue {@code true} if the parse method returns BigDecimal;
       
  2663      *                 {@code false} otherwise
  2629      * @see #isParseBigDecimal
  2664      * @see #isParseBigDecimal
  2630      * @since 1.5
  2665      * @since 1.5
  2631      */
  2666      */
  2632     public void setParseBigDecimal(boolean newValue) {
  2667     public void setParseBigDecimal(boolean newValue) {
  2633         parseBigDecimal = newValue;
  2668         parseBigDecimal = newValue;
  2710     }
  2745     }
  2711 
  2746 
  2712     /**
  2747     /**
  2713      * Synthesizes a pattern string that represents the current state
  2748      * Synthesizes a pattern string that represents the current state
  2714      * of this Format object.
  2749      * of this Format object.
       
  2750      *
       
  2751      * @return a pattern string
  2715      * @see #applyPattern
  2752      * @see #applyPattern
  2716      */
  2753      */
  2717     public String toPattern() {
  2754     public String toPattern() {
  2718         return toPattern( false );
  2755         return toPattern( false );
  2719     }
  2756     }
  2720 
  2757 
  2721     /**
  2758     /**
  2722      * Synthesizes a localized pattern string that represents the current
  2759      * Synthesizes a localized pattern string that represents the current
  2723      * state of this Format object.
  2760      * state of this Format object.
       
  2761      *
       
  2762      * @return a localized pattern string
  2724      * @see #applyPattern
  2763      * @see #applyPattern
  2725      */
  2764      */
  2726     public String toLocalizedPattern() {
  2765     public String toLocalizedPattern() {
  2727         return toPattern( true );
  2766         return toPattern( true );
  2728     }
  2767     }
  3047      * <p>
  3086      * <p>
  3048      * There is no limit to integer digits set
  3087      * There is no limit to integer digits set
  3049      * by this routine, since that is the typical end-user desire;
  3088      * by this routine, since that is the typical end-user desire;
  3050      * use setMaximumInteger if you want to set a real value.
  3089      * use setMaximumInteger if you want to set a real value.
  3051      * For negative numbers, use a second pattern, separated by a semicolon
  3090      * For negative numbers, use a second pattern, separated by a semicolon
  3052      * <P>Example <code>"#,#00.0#"</code> -> 1,234.56
  3091      * <P>Example <code>"#,#00.0#"</code> &rarr; 1,234.56
  3053      * <P>This means a minimum of 2 integer digits, 1 fraction digit, and
  3092      * <P>This means a minimum of 2 integer digits, 1 fraction digit, and
  3054      * a maximum of 2 fraction digits.
  3093      * a maximum of 2 fraction digits.
  3055      * <p>Example: <code>"#,#00.0#;(#,#00.0#)"</code> for negatives in
  3094      * <p>Example: <code>"#,#00.0#;(#,#00.0#)"</code> for negatives in
  3056      * parentheses.
  3095      * parentheses.
  3057      * <p>In negative patterns, the minimum and maximum counts are ignored;
  3096      * <p>In negative patterns, the minimum and maximum counts are ignored;
  3058      * these are presumed to be set in the positive pattern.
  3097      * these are presumed to be set in the positive pattern.
  3059      *
  3098      *
       
  3099      * @param pattern a new pattern
  3060      * @exception NullPointerException if <code>pattern</code> is null
  3100      * @exception NullPointerException if <code>pattern</code> is null
  3061      * @exception IllegalArgumentException if the given pattern is invalid.
  3101      * @exception IllegalArgumentException if the given pattern is invalid.
  3062      */
  3102      */
  3063     public void applyPattern(String pattern) {
  3103     public void applyPattern(String pattern) {
  3064         applyPattern(pattern, false);
  3104         applyPattern(pattern, false);
  3073      * <p>
  3113      * <p>
  3074      * There is no limit to integer digits set
  3114      * There is no limit to integer digits set
  3075      * by this routine, since that is the typical end-user desire;
  3115      * by this routine, since that is the typical end-user desire;
  3076      * use setMaximumInteger if you want to set a real value.
  3116      * use setMaximumInteger if you want to set a real value.
  3077      * For negative numbers, use a second pattern, separated by a semicolon
  3117      * For negative numbers, use a second pattern, separated by a semicolon
  3078      * <P>Example <code>"#,#00.0#"</code> -> 1,234.56
  3118      * <P>Example <code>"#,#00.0#"</code> &rarr; 1,234.56
  3079      * <P>This means a minimum of 2 integer digits, 1 fraction digit, and
  3119      * <P>This means a minimum of 2 integer digits, 1 fraction digit, and
  3080      * a maximum of 2 fraction digits.
  3120      * a maximum of 2 fraction digits.
  3081      * <p>Example: <code>"#,#00.0#;(#,#00.0#)"</code> for negatives in
  3121      * <p>Example: <code>"#,#00.0#;(#,#00.0#)"</code> for negatives in
  3082      * parentheses.
  3122      * parentheses.
  3083      * <p>In negative patterns, the minimum and maximum counts are ignored;
  3123      * <p>In negative patterns, the minimum and maximum counts are ignored;
  3084      * these are presumed to be set in the positive pattern.
  3124      * these are presumed to be set in the positive pattern.
  3085      *
  3125      *
       
  3126      * @param pattern a new pattern
  3086      * @exception NullPointerException if <code>pattern</code> is null
  3127      * @exception NullPointerException if <code>pattern</code> is null
  3087      * @exception IllegalArgumentException if the given pattern is invalid.
  3128      * @exception IllegalArgumentException if the given pattern is invalid.
  3088      */
  3129      */
  3089     public void applyLocalizedPattern(String pattern) {
  3130     public void applyLocalizedPattern(String pattern) {
  3090         applyPattern(pattern, true);
  3131         applyPattern(pattern, true);