Five 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.
3 REPLIES
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
Five Stars

Re: How to convert string to integer in tmap.

Thanks for reply laurent.