How to convert string to integer in tmap.

Six Stars

How to convert string to integer in tmap.

I have input field row1.COMMON_PAR_VALUE in string format, but output field having type BigDecimal.
I want to convert this string datatype to respective output datatype.
I would try with following:
Integer.parseInt(row1.COMMON_PAR_VALUE)
and
Float.parseFloat(row1.COMMON_PAR_VALUE)
But above two expression gives error:
Exception in component tRowGenerator_1

Please help.
Moderator

Re: How to convert string to integer in tmap.

Hi,
Did you want to convert "String" to " BigDecimal" or "Integer"? If later, the Integer.parseInt(row1.COMMON_PAR_VALUE) should be och. If former, you should use
java.math.BigDecimal(row1.COMMON_PAR_VALUE)

.
Could you please upload your tMap setting screenshot into forum so that we can address your issue quickly.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seventeen Stars

Re: How to convert string to integer in tmap.

hi all,
I suggest to use the tConvertType component for this.
https://help.talend.com/search/all?query=tConvertType&content-lang=en
regards
laurent
Six Stars

Re: How to convert string to integer in tmap.

Thanks for reply laurent.

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch 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