Suppose you have a date in the format yyyy/MM/DD HH:MM:ss, and you want to convert like DD-MM-yyyy HH:MM:ss. How will you do in Talend. I am going to show you demo.
1. If you want to display the current System date to any format, you can use talend Function as:
TalendDate.getDate("yyyy-MM-dd HH:MM:ss").
This will simply display the current date time in this format. For Example: 2021-09-23 15:09:56
Screenshot:
Output of the Above code is:
You can use this code whereever you want for example in the tJavaRow, tSetGlobalVar, tFixedFlowInput, tMap components etc...
On the similar manner if we have date already given then for converting that date to specific format, first of all you need to parse the date and then give pattern of specific format.
For parsing the date there is a function :
suppose date = "2018/09/20 12:34:45"
for parsing this date, TalendDate.parseDate("yyyy/MM/DD HH:mm:ss", date);
TalendDate.formatDate("yyyy-MM-DD HH:mm:ss", TalendDate.parseDate("yyyy/MM/DD HH:mm:ss", date))


Comments
Post a Comment