Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I am a newbie to talend. Please help me to implemement below logic in Talend.
if (In_Date_Check = '1') then
Out_Years := date_diff(to_date(CURDATE('DD/MM/YYYY'), 'DD/MM/YYYY'), In_Date, 'Y')
if (Out_Years < 0) then
Out_Status := 'Valid'
Out_Status_Note := 'Age is negative'
elseif (Out_Years >= 0 and Out_Years < 18) then
Out_Status := 'Valid'
Out_Status_Note := 'Minor'
elseif (Out_Years >= 18 and Out_Years <= 120) then
Out_Status := 'Valid'
Out_Status_Note := 'Adult'
else
Out_Status := 'Invalid'
Out_Status_Note := 'Current age is over 120 years'
endif
else
Out_Status := 'Invalid'
Out_Status_Note := 'Invalid date input'
endif
You can use ternary notation to replace "if-then-else" like this:
"AAA".equals(row1.field1) ? "Only A" : "BBB".equals(row1.field1) ? "Only B" : "Something else"
You can combine as many levels as needed but more than 3 or 4 make code difficult to read/maintain.
To get current date use the following expression:
TalendDate.getCurrentDate()
Finally to compare dates, use:
TalendDate.compareDate(myDate1, myDate2)
This will render -1 if first date is less than second one, 0 if both are equals and 1 if first date is bigger than second.
Thanks for the reply. I was doing as per this way only but If I test that code in Expression tab it always throws some java error.
ERROR-Exception in thread 'main'. Unresolved compilation error. For simple codes also it throws some erro
I have sent a private message.