Function tJavaFlex enables you to enter a personalized code in order to integrate it in TALEND program. With tJavaFlex, you can enter the three java-code parts (start, main and end) that constitute a kind of component dedicated to do a desired operation.
Table of Contents
Purpose tJavaFlex lets you add Java code to the Start/Main/End code sections of this component itself.
If you would like to Enrich your career with a Talend certified professional, then visit Mindmajix - A Global online training platform: “Talend Certification Training” Course. This course will help you to achieve excellence in this domain.
System.out.println("## STARTn#");
int i = 0;
In this example, the code indicates the end of the execution of tJavaFlex by displaying the END message:
System.out.println("#n## END");
Frequently Asked TALEND Interview Questions & Answers
Lot of time, we come across a situation where we want to use the custom routines/functions while creating Talend Job. Custom routines can be handy and re-usable code when required to be used more than one time.
Here, let us create a simple routine to convert String to Date data type. The user will pass the date in string format and the actual date format of the string to the routine and in return routine will provide the Date.
Follow below mentioned steps to create a user routine:
------ Check Out Talend Tutorials ------
package routines;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class string_to_date {
public static Date convert2Date(String string_date,String date_format) throws Exception
{
SimpleDateFormat sdf = new SimpleDateFormat(date_format);
Date transformed_date = sdf.parse(string_date);
return transformed_date;
}
}
Now our routine is ready. Its time to use this routine.
Copy and paste below code
String string_date = "2013-03-15";
String date_format = "yyyy-MM-dd";
Date transformed_date = routines.string_to_date.convert2Date(string_date, date_format);
Calendar cal = Calendar.getInstance();
cal.setTime(transformed_date);
System.out.println("nYear part is = " + cal.get(Calendar.YEAR));
System.out.println("nMonth part is = " + cal.get(Calendar.MONTH));
System.out.println("nDay part is = " + cal.get(Calendar.DAY_OF_MONTH));
System.out.println("String has been transformed to Date datatype = "+ transformed_date.toString() );
Now our job is complete. It’s time to execute it.
Now, you can see that date in the form of String has been converted to Date data type. You can call this routine whenever you require to convert string to Date. Just provide the string literal and its format to the routine defined above.
Name | Dates | |
---|---|---|
Talend Training | Oct 19 to Nov 03 | View Details |
Talend Training | Oct 22 to Nov 06 | View Details |
Talend Training | Oct 26 to Nov 10 | View Details |
Talend Training | Oct 29 to Nov 13 | View Details |
Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.