Specify date format in talend

2.8k Views Asked by At

I have used TalendDate.addDate(TalendDate.getCurrentDate(),-1,"DD") and the out put is "Wed Dec 28 23:51:27 IST 2016" . I want it in "2016-12-28" format.

Is there any way to get that?

Thanks in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

This code will format it how you want it.

TalendDate.formatDate("yyyy-MM-dd",TalendDate.addDate(TalendDate.getCurrentDate(),-1,"DD"))
0
On

Be sure that in your output component, a date model is defined for this field.

Example below with a tLogRow