Class StringToBigDecimalConverter

  • All Implemented Interfaces:
    Converter<java.lang.String,​java.math.BigDecimal>, java.io.Serializable

    public class StringToBigDecimalConverter
    extends AbstractStringToNumberConverter<java.math.BigDecimal>
    A converter that converts from String to BigDecimal and back. Uses the given locale and a NumberFormat instance for formatting and parsing.

    Leading and trailing white spaces are ignored when converting from a String.

    Override and overwrite getFormat(Locale) to use a different format.

    Since:
    8.0
    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Constructor Detail

      • StringToBigDecimalConverter

        public StringToBigDecimalConverter​(java.lang.String errorMessage)
        Creates a new converter instance with the given error message. Empty strings are converted to null.
        Parameters:
        errorMessage - the error message to use if conversion fails
      • StringToBigDecimalConverter

        public StringToBigDecimalConverter​(java.math.BigDecimal emptyValue,
                                           java.lang.String errorMessage)
        Creates a new converter instance with the given empty string value and error message.
        Parameters:
        emptyValue - the presentation value to return when converting an empty string, may be null
        errorMessage - the error message to use if conversion fails
      • StringToBigDecimalConverter

        public StringToBigDecimalConverter​(ErrorMessageProvider errorMessageProvider)
        Creates a new converter instance with the given error message provider. Empty strings are converted to null.
        Parameters:
        errorMessageProvider - the error message provider to use if conversion fails
        Since:
        8.4
      • StringToBigDecimalConverter

        public StringToBigDecimalConverter​(java.math.BigDecimal emptyValue,
                                           ErrorMessageProvider errorMessageProvider)
        Creates a new converter instance with the given empty string value and error message provider.
        Parameters:
        emptyValue - the presentation value to return when converting an empty string, may be null
        errorMessageProvider - the error message provider to use if conversion fails
        Since:
        8.4