Converting local time format into UTC format and vice versa using Talend

0 votes

How do I convert a local database which contains the data in local time format? Now I want to load this data into a central MySQL database which contains the data in UTC format. Can anyone suggest how do I convert my local time into UTC and vice-versa in Talend?

Examples: 

23-10-2015 16:00 Local time => 23-10-2015 14:00 UTC (and vice versa) 

26-10-2015 16:00 Local time => 26-10-2015 15:00 UTC (and vice versa)

Apr 18, 2018 in Talend by anto.trigg4
• 3,440 points
3,171 views

1 answer to this question.

0 votes

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.

image

Once you are done, follow the below steps:

  1. Go to the component tab of the tFixedFlowInput component and specify the schema as shown below:image    

  2. Once done, select the Inline table option and provide the data as per requirement:image

  3. 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;
  4. 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;
  5. In the component tab of tLogRow, select the highlighted option in order to print in the key-value pair.image

  6. Now execute the job. You will get the required output:

image

Hope this will help!

Join the Talend course today to know more about and become expert.

Thanks.

answered Apr 18, 2018 by misc.edu04
• 1,450 points

Related Questions In Talend

0 votes
1 answer
0 votes
1 answer

Converting Columns into Rows in Talend

Hi, You can try using tNormalize component along ...READ MORE

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points

edited Apr 11, 2018 by code.reaper12 6,494 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

tWaitForFile component insufficiency in Talend

Regarding your first issue, tWaitForFile component provides ...READ MORE

answered Apr 11, 2018 in Talend by geek.erkami
• 2,680 points
2,480 views
0 votes
1 answer

How to load a set of files into database using Talend

Using tFileList component,  you can read all the files present ...READ MORE

answered Apr 17, 2018 in Talend by code.reaper12
• 3,500 points
6,150 views
0 votes
1 answer

Using tHiveRow to execute multiple Hive queries in Talend

In order to execute multiple queries, you ...READ MORE

answered Apr 14, 2018 in Talend by misc.edu04
• 1,450 points
3,827 views
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP