Class BigDecimalCurrencyConverter
- java.lang.Object
-
- javafx.util.StringConverter<java.math.BigDecimal>
-
- com.palmer.billingstatementgenerator.util.BigDecimalCurrencyConverter
-
public class BigDecimalCurrencyConverter extends javafx.util.StringConverter<java.math.BigDecimal>A JavaFXStringConverterforBigDecimalvalues formatted as currency. Used withTextFormatteron price input fields to display values in currency format and parse user input back toBigDecimal.Formatting uses the system's default currency locale via
NumberFormat.getCurrencyInstance(). Parsing strips all non-numeric characters (except decimal points) before converting.
-
-
Constructor Summary
Constructors Constructor Description BigDecimalCurrencyConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimalfromString(java.lang.String text)Parses a currency string into aBigDecimalby stripping non-numeric characters before converting.java.lang.StringtoString(java.math.BigDecimal value)Converts aBigDecimalvalue to a formatted currency string.
-
-
-
Method Detail
-
toString
public java.lang.String toString(java.math.BigDecimal value)
Converts aBigDecimalvalue to a formatted currency string.- Specified by:
toStringin classjavafx.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 aBigDecimalby stripping non-numeric characters before converting.- Specified by:
fromStringin classjavafx.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
-
-