I am trying to format a string into a specific format only if it is numeric.
I am using the following expression in the tmap.
Mathematical.NUM(row.number) ? String.format("%010d", Double.parseDouble(row.number)) : row.number
I am getting a compilation error:
Type Mismatch: Cannot convert int to boolean.
Could you please elaborate your case with an example with input and expected output values?
Would you mind posting your tMap editor screenshot into forum?
Best regards
Sabrina
You are getting that error since that 1-line if-else statement needs a
BOOLEAN expression at the left side, but Mathematical.NUM returns an
INTEGER value 1 if the parameter passed is a numeric data type, or 0 if otherwise. So you have to add a bit of code to your decision statement, such that it checks if the returned value is equal to 1 or not (added code in red bold):
Mathematical.NUM(row.number) == 1? String.format("%010d", Double.parseDouble(row.number)) : row.number