Support Questions

Find answers, ask questions, and share your expertise

Nifi Epoch conversion not working?

avatar
Explorer

Hi,

Can anyone shed some light on this, please.

having:

attribute 'epochdatetime' Value: '1545266262' and

using:

UpdateAttribute to create new variable 'converteddatetime' with

${epochdatetime:format("yyyy/MM/dd HH:mm:ss.SSS'Z'", "GMT")}

gives:

converteddatetime' Value: '1970/01/18 21:14:26.262Z'

instead of: December 20, 2018/12/20 12:37:42......

1 ACCEPTED SOLUTION

avatar
Super Collaborator

Hi @A Sabatino,

I am not sure why you expect the date resulting from your epoch value. So from what I can see, your value is not what you expect, the conversion is fine.

In the API documentation (https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#dates) it is desribed, that the value ist interpreted in milliseconds from 1. January 1970 00:00:00 GMT. Now when interpreting '1 545 266 262', it results in something like 17.8 days. So a time on the 18. January 1970 seems to be the correct result. To me it appears as if you lost a factor of 1000 somewhere in your epoch value.

Regards
Harald


View solution in original post

5 REPLIES 5

avatar
Super Collaborator

Hi @A Sabatino,

I am not sure why you expect the date resulting from your epoch value. So from what I can see, your value is not what you expect, the conversion is fine.

In the API documentation (https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#dates) it is desribed, that the value ist interpreted in milliseconds from 1. January 1970 00:00:00 GMT. Now when interpreting '1 545 266 262', it results in something like 17.8 days. So a time on the 18. January 1970 seems to be the correct result. To me it appears as if you lost a factor of 1000 somewhere in your epoch value.

Regards
Harald


avatar
Explorer

Hi Harald

You are right - we passed in the epoch in seconds rather than milliseconds !

Many thanks

Regards

Aniello

avatar
Super Collaborator

Hi @A Sabatino,

thanks for the info. Would be great if you click on 'accept' for the answer. Helps everyone to see the issue is resolved and provides you and me with a reward in terms of reputation points 🙂

Regards
Harald

avatar
New Contributor

Hi @A Sabatino,
I am also facing same issue for 
Value: '1643667489'
Could you please share complete syntax for the epoch(1643667489) in second....

avatar
Community Manager

Hi @AshuGang as this is an older post, you would have a better chance of receiving a resolution by starting a new thread. This will also be an opportunity to provide details specific to your environment that could aid others in assisting you with a more accurate answer to your question. You can link this thread as a reference in your new post.



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community: