This job is pretty simple. In order to perform the conversion of local time into UTC you need to do is to add tFixedFlowInput, tJavaRow and tLogRow components into the workspace and connect them using the Row(Main) link.
Once you are done, follow the below steps:
-
Go to the component tab of the tFixedFlowInput component and specify the schema as shown below:
-
Once done, select the Inline table option and provide the data as per requirement:
-
Now, in the component tab of tJava component, go to the advanced settings and import the given packages:
import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; import java.text.ParseException;
-
Now, go to the basic settings of the tab and add the following code:
String BASE_FORMAT = "dd-MM-yyyy HH:mm";
TimeZone utc = TimeZone.getTimeZone("UTC");
TimeZone local = TimeZone.getTimeZone("Europe/Amsterdam");
SimpleDateFormat formatUTC = new SimpleDateFormat( BASE_FORMAT );
formatUTC.setTimeZone(utc);
SimpleDateFormat formatCE = new SimpleDateFormat( BASE_FORMAT );
formatCE.setTimeZone(local);
row2.localDateTime = row1.localDateTime;
-
In the component tab of tLogRow, select the highlighted option in order to print in the key-value pair.
-
Now execute the job. You will get the required output:
Hope this will help!
Join the Talend course today to know more about and become expert.
Thanks.