org.springframework.format.number

Class CurrencyStyleFormatter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      protected java.text.NumberFormat getNumberFormat(java.util.Locale locale)
      Obtain a concrete NumberFormat for the specified locale.
      java.math.BigDecimal parse(java.lang.String text, java.util.Locale locale)
      Parse a text String to produce a T.
      void setCurrency(java.util.Currency currency)
      Specify the currency, if known.
      void setFractionDigits(int fractionDigits)
      Specify the desired number of fraction digits.
      void setPattern(java.lang.String pattern)
      Specify the pattern to use to format number values.
      void setRoundingMode(java.math.RoundingMode roundingMode)
      Specify the rounding mode to use for decimal parsing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CurrencyStyleFormatter

        public CurrencyStyleFormatter()
    • Method Detail

      • setFractionDigits

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

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

        public void setCurrency(java.util.Currency currency)
        Specify the currency, if known.
      • setPattern

        public void setPattern(java.lang.String pattern)
        Specify the pattern to use to format number values. If not specified, the default DecimalFormat pattern is used.
        See Also:
        DecimalFormat.applyPattern(String)
      • parse

        public java.math.BigDecimal parse(java.lang.String text,
                                          java.util.Locale locale)
                                   throws java.text.ParseException
        Description copied from interface: Parser
        Parse a text String to produce a T.
        Specified by:
        parse in interface Parser<java.lang.Number>
        Overrides:
        parse in class AbstractNumberFormatter
        Parameters:
        text - the text string
        locale - the current user locale
        Returns:
        an instance of T
        Throws:
        java.text.ParseException - when a parse exception occurs in a java.text parsing library
      • getNumberFormat

        protected java.text.NumberFormat getNumberFormat(java.util.Locale locale)
        Description copied from class: AbstractNumberFormatter
        Obtain a concrete NumberFormat for the specified locale.
        Specified by:
        getNumberFormat in class AbstractNumberFormatter
        Parameters:
        locale - the current locale
        Returns:
        the NumberFormat instance (never null)