
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert a string to Big Decimal
I have the following string in a csv delimeted file that I need to convert to a BigDecimal :
"$6.00"
Thanks again
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the `BigDecimal` class in Java to convert the string "$6.00" to a `BigDecimal` object. Here's an example code snippet that shows how to do this:
String str = "$6.00";
BigDecimal bd = new BigDecimal(str.replace("$", ""));
Explanation:
We start by initializing a string variable `str` with the value "$6.00".
We then create a `BigDecimal` object `bd` by passing the string `str` to the constructor of `BigDecimal`.
However, since the string `str` contains a currency symbol "$" that is not valid in a `BigDecimal` object, we remove it using the `replace()` method. The resulting string "6.00" can then be converted to a `BigDecimal` object using its constructor.
Note that you may also need to handle any potential exceptions that can be thrown by the `BigDecimal` constructor, such as `NumberFormatException` if the input string is not a valid decimal number. SkyWard Alpine Login

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try this expression on tJavaRow
output_row.data = new java.math.BigDecimal(input_row.data.replace("$",""));
or on tMap:
new java.math.BigDecimal(row1.data.replace("$",""))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the `BigDecimal` class in Java to convert the string "$6.00" to a `BigDecimal` object. Here's an example code snippet that shows how to do this:
String str = "$6.00";
BigDecimal bd = new BigDecimal(str.replace("$", ""));
Explanation:
We start by initializing a string variable `str` with the value "$6.00".
We then create a `BigDecimal` object `bd` by passing the string `str` to the constructor of `BigDecimal`.
However, since the string `str` contains a currency symbol "$" that is not valid in a `BigDecimal` object, we remove it using the `replace()` method. The resulting string "6.00" can then be converted to a `BigDecimal` object using its constructor.
Note that you may also need to handle any potential exceptions that can be thrown by the `BigDecimal` constructor, such as `NumberFormatException` if the input string is not a valid decimal number. SkyWard Alpine Login
