Class BigDecimalCurrencyConverter


  • public class BigDecimalCurrencyConverter
    extends javafx.util.StringConverter<java.math.BigDecimal>
    A JavaFX StringConverter for BigDecimal values formatted as currency. Used with TextFormatter on price input fields to display values in currency format and parse user input back to BigDecimal.

    Formatting uses the system's default currency locale via NumberFormat.getCurrencyInstance(). Parsing strips all non-numeric characters (except decimal points) before converting.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.math.BigDecimal fromString​(java.lang.String text)
      Parses a currency string into a BigDecimal by stripping non-numeric characters before converting.
      java.lang.String toString​(java.math.BigDecimal value)
      Converts a BigDecimal value to a formatted currency string.
      • Methods inherited from class java.lang.Object

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

      • BigDecimalCurrencyConverter

        public BigDecimalCurrencyConverter()
    • Method Detail

      • toString

        public java.lang.String toString​(java.math.BigDecimal value)
        Converts a BigDecimal value to a formatted currency string.
        Specified by:
        toString in class javafx.util.StringConverter<java.math.BigDecimal>
        Parameters:
        value - the value to format, or null
        Returns:
        the formatted currency string, or an empty string if value is null
      • fromString

        public java.math.BigDecimal fromString​(java.lang.String text)
        Parses a currency string into a BigDecimal by stripping non-numeric characters before converting.
        Specified by:
        fromString in class javafx.util.StringConverter<java.math.BigDecimal>
        Parameters:
        text - the input string, potentially containing currency symbols or commas
        Returns:
        the parsed BigDecimal, or null if the input is blank or unparseable