How to convert object datatype to bigdecimal/double

Four Stars

How to convert object datatype to bigdecimal/double

I am using source as ms sql in talend big data version. There is data type as Money. While fetching schema from db. The data type changed to object. Now I need to convert it to BigDecimal or Double in tmap. I Tried to use new Bigdecimal(column name).But Its not working.


Thanks in advance.

Employee

Re: How to convert object datatype to bigdecimal/double

Can you try to set the schema in your MSSQL component to Big Decimal there so that it retrieves it as a big decimal?  

If not, then you need to understand what the object contains first.  If it is a String, then you can cast the object to a String first like:

 

new BigDecima((String)columnname)

 

See the BigDecimal constructors here https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html  

There is no constructor for generic Object type.  Hence, you will need to know what is in the Object and cast accordingly.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog