[resolved] Tmap - String to Int - And return null if null
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)
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)
Hi Shong,
I would appreciate it if you could tell me what is the Talend best practice for the following scenario:
I receive input as an XML document and use tXMLMap to split the fields (Which are all string) but some of them are supposed to be inserted into the database as decimal and some as int. So shall I do the converting of strings to BigDecimal and int within tXMLMap and then check if the required fields have been filled in at tFilterRow or shall I do both converting and checking in tFilterRow?
Also, the filtering code is quite long in tFilterRow so shall I create routines and call them - any advice on this will be greatly appreciated.
Best regards,
Shujel