Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Nifi Epoch conversion not working?

Solved Go to solution
Highlighted

Nifi Epoch conversion not working?

New Contributor

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

Accepted Solutions

Re: Nifi Epoch conversion not working?

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


3 REPLIES 3

Re: Nifi Epoch conversion not working?

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


Re: Nifi Epoch conversion not working?

New Contributor

Hi Harald

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

Many thanks

Regards

Aniello

Re: Nifi Epoch conversion not working?

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