< prev index next >

src/java.base/share/classes/java/text/NumberFormat.java

Print this page
rev 55871 : 8215181: Accounting currency format support
Reviewed-by:


 558     }
 559 
 560     /**
 561      * Returns a currency format for the current default
 562      * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
 563      * <p>This is equivalent to calling
 564      * {@link #getCurrencyInstance(Locale)
 565      *     getCurrencyInstance(Locale.getDefault(Locale.Category.FORMAT))}.
 566      *
 567      * @return the {@code NumberFormat} instance for currency formatting
 568      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 569      * @see java.util.Locale.Category#FORMAT
 570      */
 571     public static final NumberFormat getCurrencyInstance() {
 572         return getInstance(Locale.getDefault(Locale.Category.FORMAT), null, CURRENCYSTYLE);
 573     }
 574 
 575     /**
 576      * Returns a currency format for the specified locale.
 577      *









 578      * @param inLocale the desired locale
 579      * @return the {@code NumberFormat} instance for currency formatting
 580      */
 581     public static NumberFormat getCurrencyInstance(Locale inLocale) {
 582         return getInstance(inLocale, null, CURRENCYSTYLE);
 583     }
 584 
 585     /**
 586      * Returns a percentage format for the current default
 587      * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
 588      * <p>This is equivalent to calling
 589      * {@link #getPercentInstance(Locale)
 590      *     getPercentInstance(Locale.getDefault(Locale.Category.FORMAT))}.
 591      *
 592      * @return the {@code NumberFormat} instance for percentage formatting
 593      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 594      * @see java.util.Locale.Category#FORMAT
 595      */
 596     public static final NumberFormat getPercentInstance() {
 597         return getInstance(Locale.getDefault(Locale.Category.FORMAT), null, PERCENTSTYLE);




 558     }
 559 
 560     /**
 561      * Returns a currency format for the current default
 562      * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
 563      * <p>This is equivalent to calling
 564      * {@link #getCurrencyInstance(Locale)
 565      *     getCurrencyInstance(Locale.getDefault(Locale.Category.FORMAT))}.
 566      *
 567      * @return the {@code NumberFormat} instance for currency formatting
 568      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 569      * @see java.util.Locale.Category#FORMAT
 570      */
 571     public static final NumberFormat getCurrencyInstance() {
 572         return getInstance(Locale.getDefault(Locale.Category.FORMAT), null, CURRENCYSTYLE);
 573     }
 574 
 575     /**
 576      * Returns a currency format for the specified locale.
 577      *
 578      * <p>If the specified locale contains the "{@code cf}" (
 579      * <a href="https://www.unicode.org/reports/tr35/tr35.html#UnicodeCurrencyFormatIdentifier">
 580      * currency format style</a>)
 581      * <a href="../util/Locale.html#def_locale_extension">Unicode extension</a>,
 582      * the returned currency format uses the style if it is available.
 583      * Otherwise, the style uses the default "{@code standard}" currency format.
 584      * For example, if the style designates "{@code account}", negative
 585      * currency amounts use a pair of parentheses in some locales.
 586      *
 587      * @param inLocale the desired locale
 588      * @return the {@code NumberFormat} instance for currency formatting
 589      */
 590     public static NumberFormat getCurrencyInstance(Locale inLocale) {
 591         return getInstance(inLocale, null, CURRENCYSTYLE);
 592     }
 593 
 594     /**
 595      * Returns a percentage format for the current default
 596      * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
 597      * <p>This is equivalent to calling
 598      * {@link #getPercentInstance(Locale)
 599      *     getPercentInstance(Locale.getDefault(Locale.Category.FORMAT))}.
 600      *
 601      * @return the {@code NumberFormat} instance for percentage formatting
 602      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 603      * @see java.util.Locale.Category#FORMAT
 604      */
 605     public static final NumberFormat getPercentInstance() {
 606         return getInstance(Locale.getDefault(Locale.Category.FORMAT), null, PERCENTSTYLE);


< prev index next >