One Star

converting String to Integer error - tmap

Hi,
I am stuck with this error and unable to figure out what's wrong the expression, I am converting a string value to integer based on the condition, below is the expression I have added in the tMap
(StringHandling.TRIM(Source.SR_Current_SA_Number.toString()) == "Not Available")?Integer.parseInt("0".toString()):Integer.parseInt(StringHandling.TRIM(Source.SR_Current_SA_Number.toString()))

Error exception :
Exception in component tMap_1
java.lang.NumberFormatException: For input string: "Not Available"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.valueOf(Integer.java:554)
at nexus.import_closed_cases_0_1.Import_Closed_Cases.tOracleInput_1Process(Import_Closed_Cases.java:2379)
at nexus.import_closed_cases_0_1.Import_Closed_Cases.runJobInTOS(Import_Closed_Cases.java:3076)
at nexus.import_closed_cases_0_1.Import_Closed_Cases.main(Import_Closed_Cases.java:2947)
-------
Any help wil be much appreciated.
Thanks,
Naran
1 REPLY
Community Manager

Re: converting String to Integer error - tmap

Hi
In Java, to determine whether two strings are equal should use string1.equals("string2"), try this expression:
(StringHandling.TRIM(Source.SR_Current_SA_Number.toString()) .equals("Not Available"))?Integer.parseInt("0".toString()):Integer.parseInt(StringHandling.TRIM(Source.SR_Current_SA_Number.toString()))
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business