org.springframework.format.number.money

## 类 MonetaryAmountFormatter

- java.lang.Object
- - org.springframework.format.number.money.MonetaryAmountFormatter

- 所有已实现的接口:
    Formatter<javax.money.MonetaryAmount>, Parser<javax.money.MonetaryAmount>, Printer<javax.money.MonetaryAmount>

      public class MonetaryAmountFormatter
      extends Object
      implements Formatter<javax.money.MonetaryAmount>

  Formatter for JSR-354 `MonetaryAmount` values, delegating to `MonetaryAmountFormat.format(javax.money.MonetaryAmount)` and `MonetaryAmountFormat.parse(java.lang.CharSequence)`.
  从以下版本开始:
    4.2
  作者:
    Juergen Hoeller
  另请参阅:
    `getMonetaryAmountFormat(java.util.Locale)`

- - ### 构造器概要

    构造器
    构造器和说明
    `MonetaryAmountFormatter()` Create a locale-driven MonetaryAmountFormatter.
    `MonetaryAmountFormatter(String formatName)` Create a new MonetaryAmountFormatter for the given format name.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected javax.money.format.MonetaryAmountFormat` | `getMonetaryAmountFormat(Locale locale)` Obtain a MonetaryAmountFormat for the given locale.
    `javax.money.MonetaryAmount` | `parse(String text, Locale locale)` Parse a text String to produce a T.
    `String` | `print(javax.money.MonetaryAmount object, Locale locale)` Print the object of type T for display.
    `void` | `setFormatName(String formatName)` Specify the format name, to be resolved by the JSR-354 provider at runtime.

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

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

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

    - #### MonetaryAmountFormatter

          public MonetaryAmountFormatter()

      Create a locale-driven MonetaryAmountFormatter.

    - #### MonetaryAmountFormatter

          public MonetaryAmountFormatter(String formatName)

      Create a new MonetaryAmountFormatter for the given format name.
      参数:
        `formatName` - the format name, to be resolved by the JSR-354 provider at runtime

  - ### 方法详细资料

    - #### setFormatName

          public void setFormatName(String formatName)

      Specify the format name, to be resolved by the JSR-354 provider at runtime.

      Default is none, obtaining a `MonetaryAmountFormat` based on the current locale.

    - #### print

          public String print(javax.money.MonetaryAmount object,
                              Locale locale)

      从接口复制的说明: `Printer`
      Print the object of type T for display.
      指定者:
        `print` 在接口中 `Printer<javax.money.MonetaryAmount>`
      参数:
        `object` - the instance to print
        `locale` - the current user locale
      返回:
        the printed text string

    - #### parse

          public javax.money.MonetaryAmount parse(String text,
                                                  Locale locale)

      从接口复制的说明: `Parser`
      Parse a text String to produce a T.
      指定者:
        `parse` 在接口中 `Parser<javax.money.MonetaryAmount>`
      参数:
        `text` - the text string
        `locale` - the current user locale
      返回:
        an instance of T

    - #### getMonetaryAmountFormat

          protected javax.money.format.MonetaryAmountFormat getMonetaryAmountFormat(Locale locale)

      Obtain a MonetaryAmountFormat for the given locale.

      The default implementation simply calls `MonetaryFormats.getAmountFormat(java.util.Locale, java.lang.String...)` with either the configured format name or the given locale.

      参数:
        `locale` - the current locale
      返回:
        the MonetaryAmountFormat (never `null`)
      另请参阅:
        `setFormatName(java.lang.String)`