org.springframework.format.number

## 类 CurrencyStyleFormatter

- java.lang.Object
- - org.springframework.format.number.AbstractNumberFormatter
  - - org.springframework.format.number.CurrencyStyleFormatter

- 所有已实现的接口:
    Formatter<Number>, Parser<Number>, Printer<Number>

      public class CurrencyStyleFormatter
      extends AbstractNumberFormatter

  A BigDecimal formatter for number values in currency style.

  Delegates to `NumberFormat.getCurrencyInstance(Locale)`. Configures BigDecimal parsing so there is no loss of precision. Can apply a specified `RoundingMode` to parsed values.

  从以下版本开始:
    4.2
  作者:
    Keith Donald, Juergen Hoeller
  另请参阅:
    `AbstractNumberFormatter.setLenient(boolean)`, `setRoundingMode(java.math.RoundingMode)`

- - ### 构造器概要

    构造器
    构造器和说明
    `CurrencyStyleFormatter()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected NumberFormat` | `getNumberFormat(Locale locale)` Obtain a concrete NumberFormat for the specified locale.
    `BigDecimal` | `parse(String text, Locale locale)` Parse a text String to produce a T.
    `void` | `setCurrency(Currency currency)` Specify the currency, if known.
    `void` | `setFractionDigits(int fractionDigits)` Specify the desired number of fraction digits.
    `void` | `setPattern(String pattern)` Specify the pattern to use to format number values.
    `void` | `setRoundingMode(RoundingMode roundingMode)` Specify the rounding mode to use for decimal parsing.

    - ### 从类继承的方法 org.springframework.format.number.AbstractNumberFormatter

      `print, setLenient`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### CurrencyStyleFormatter

          public CurrencyStyleFormatter()

  - ### 方法详细资料

    - #### setFractionDigits

          public void setFractionDigits(int fractionDigits)

      Specify the desired number of fraction digits. Default is 2.

    - #### setRoundingMode

          public void setRoundingMode(RoundingMode roundingMode)

      Specify the rounding mode to use for decimal parsing. Default is `RoundingMode.UNNECESSARY`.

    - #### setCurrency

          public void setCurrency(Currency currency)

      Specify the currency, if known.

    - #### setPattern

          public void setPattern(String pattern)

      Specify the pattern to use to format number values. If not specified, the default DecimalFormat pattern is used.
      另请参阅:
        `DecimalFormat.applyPattern(String)`

    - #### parse

          public BigDecimal parse(String text,
                                  Locale locale)
                           throws ParseException

      从接口复制的说明: `Parser`
      Parse a text String to produce a T.
      指定者:
        `parse` 在接口中 `Parser<Number>`
      覆盖:
        `parse` 在类中 `AbstractNumberFormatter`
      参数:
        `text` - the text string
        `locale` - the current user locale
      返回:
        an instance of T
      抛出:
        `ParseException` - when a parse exception occurs in a java.text parsing library

    - #### getNumberFormat

          protected NumberFormat getNumberFormat(Locale locale)

      从类复制的说明: `AbstractNumberFormatter`
      Obtain a concrete NumberFormat for the specified locale.
      指定者:
        `getNumberFormat` 在类中 `AbstractNumberFormatter`
      参数:
        `locale` - the current locale
      返回:
        the NumberFormat instance (never `null`)