Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert the System timestamp to Epoch Unix timestamp

Hi,

 

How to convert the System timestamp to Epoch Unix timestamp in talend. Is there any function like java.util.Date.gettime() to convert it into milliseconds.

 

Meaning converting yyyy-MM-dd HH:mm:ss to unix epoch timestamp.

Example 

2020/01/30 00:00:00 to Unix timestamp. Then i want to subtract the unix timestamp by 1 so that it can give me 1 sec less.

 

Can anyone help me in this ??

 

Thanks,
Abhishek

Labels (2)
9 Replies
TRF
Champion II
Champion II

Have a look at TalendDate.addDate.
You just have to use it with a negative value.
https://help.talend.com/reader/~R4Lk_SlELw9a8pKBKTm9A/97HhybirKNimDaj6MWfaDg
Anonymous
Not applicable
Author

But first i need to convert system timestamp into unix timestamp.

TRF
Champion II
Champion II

As far as I understand you question, you just have to do this:

TalendDate.addDate(TalendDate.getCurrentDate(), -1, "ss") 

It will give you the current date minus 1 second.

Just store the result to a field with datatype Date or a global variable you have to cast to Date when you want to use the content.

Anonymous
Not applicable
Author

Hi,

 

Say suppose today is 2020/1/29 00:00:00. By using 

TalendDate.addDate(TalendDate.getCurrentDate(), -1, "ss")

i get the time 2020/1/28 11:59:59 pm. Then i convert this time to Epoch timestamp i.e into 1580255999.

 

Thanks,

Abhishek 

TRF
Champion II
Champion II

To convert current date - 1 second in epoch:

TalendDate.addDate(TalendDate.getCurrentDate(), -1, "ss").getTime()

 

Anonymous
Not applicable
Author

As my server is in PST time zone 

getCurrentDate()

gives me that zone time, can i convert this into UTC time before converting into unix time. 

sam473
Contributor
Contributor

What i should give in schema to get epochunixstamp

 


unix.JPG
sam473
Contributor
Contributor

What i should give in schema to get epochunixstamp