Condition : If 0 then NULL else convert date to YYYYMMDD. How to make this in talend.
As your source can have value 0 I guess it is string value so try this
Also you have to change ports date format to yyyyMMdd from default "dd-MM-yyyy"
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
You really need to give an example of your data. I will assume that you want to convert a number to a date, rather than a String. I will also assume all months and days will be made up of 2 digits. If this is correct, you can do it as below....
row.value==0 ? null : routines.TalendDate.parseDate("yyyyMMdd", (row.value+""))
The above will convert a number to a Date object based on assuming that the number represents a date in the format yyyyMMdd. The above would be prone to errors if the number wasn't precise.
Alternatively, you may want to convert a millisecond value into a String representation of a date in the format yyyyMMdd. This might be done as below.....
row.value==0L ? null : routines.TalendDate.formatDate("yyyyMMdd", new Date(row.value))
0L is used to indicate a Long....since if this is what is required your number would have to be Long.
There are many ways to achieve a suitable answer to your question, but to get the answer you want you might want to give more detail.