Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
CSharma1636705679
Contributor
Contributor

How to convert epoch timetamp into GMT0

Hi all I am new to talend sorry for the mistakes, my question is how to convert epoch timestamp into GMT0;

I am getting epoch time = "

1631898440"

as string I tried converting it into timestamp like this -

(row1.datecolumn==null || row1.datecolumn=="" )?null:

(new java.util.Date(Long.parseLong(row1.datecolumn) * 1000)); 

with this the output that I am getting is = 2021-09-17 22:37:20 here talend is taking my system's timezone I guess.

but the time I need is = 2021-09-17 5:07:20 pm

which is GMT0

How can I achieve this please help

Labels (4)
3 Replies
Anonymous
Not applicable

Hi

Change the timezone in the begging of job, add this code on a tJava:

java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("UTC"));

 

Let me know if it works.

 

Regards

Shong

CSharma1636705679
Contributor
Contributor
Author

Hi Shong, thank you for the suggestion but it didn't work!

Anonymous
Not applicable

I tried and I am able to get the date output like this:

2021-09-17 17:07:20

if you want to have

2021-09-17 5:07:20 pm

You need to set the date pattern as "yyyy-MM-dd hh:mm:ss aa" of this column on schema.