You are not logged in.
Announcement
Unanswered posts
|
Pages: 1

This will convert a string to an integer:
Integer.parseInt(row1.value1)
How can I change this to work for converting a String to Int and return null there is no value?
(row1.value1==null)?null:TalendDate.parseDate("dd/MM/yyyy", row1.value1)
Is this close?
(row1.value1==null)?null:Integer.parseInt(row1.value1)
Last edited by talendtester (2011-04-02 04:48:00)
Offline
Hi
Is this close?
(row1.value1==null)?null:Integer.parseInt(row1.value1)
Yes, you are right. let us know if you don't get the expected result.
Best regards
Shong
Offline

I get this error:
Exception in component tMap_1
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at talenddemosjava.myJob_0_1.myJob.tFileInputDelimited_1Process(myJob.java:1171)
at talenddemosjava.myJob_0_1.myJob.runJobInTOS(myJob.java:1682)
at talenddemosjava.myJob_0_1.myJob.main(myJob.java:1556)
Offline

Hi
do it like this
(row1.value1==null || row1.value1=="" )?null:Integer.parseInt(row1.value1)
or you can use
(row1.value1.length >0 )?null:Integer.parseInt(row1.value1)
Regards
Vijay.M
Offline

Thanks mailforvijaym & shong,
I found out that my data had several bad records with less than the correct number of delimiters.
Offline
Pages: 1