Hagakure87
Hagakure87

Reputation: 137

Nifi convert UTC to unix time

I have a flowfile attribute which is a UTC datetime in the format of yyyy-MM-dd HH:mm:ss.SSS

I need to convert this to a unix timestamp.

How can this be done? I know its possible to convert Unix to the above format using Jolt:

"time": "${time:format('yyyy-MM-dd HH:mm:ss.SSS')}"

however, im not sure how to do this in reverse?

Upvotes: 2

Views: 3425

Answers (1)

Sdairs
Sdairs

Reputation: 2032

Working with attributes in this way uses the NiFi Expression Langauge (not Jolt).

See the docs here https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

${time:format('yyyy-MM-dd HH:mm:ss.SSS')}

Uses Expression Language to format the time attribute to the given SimpleDateFormat string.

${time:toNumber()}

Uses Expression Language to convert the given Date object to Epoch Millis.

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#tonumber

Upvotes: 3

Related Questions