类 CurrencyStyleFormatter

java.lang.Object
cn.taketoday.format.number.AbstractNumberFormatter
cn.taketoday.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.0
作者:
Keith Donald, Juergen Hoeller
另请参阅:
  • 构造器详细资料

    • CurrencyStyleFormatter

      public CurrencyStyleFormatter()
  • 方法详细资料

    • setFractionDigits

      public void setFractionDigits(int fractionDigits)
      Specify the desired number of fraction digits. Default is 2.
    • setRoundingMode

      public void setRoundingMode(@Nullable RoundingMode roundingMode)
      Specify the rounding mode to use for decimal parsing. Default is RoundingMode.UNNECESSARY.
    • setCurrency

      public void setCurrency(@Nullable Currency currency)
      Specify the currency, if known.
    • setPattern

      public void setPattern(@Nullable String pattern)
      Specify the pattern to use to format number values. If not specified, the default DecimalFormat pattern is used.
      另请参阅:
    • 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)