Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Converting Datetime to UnixEpoch time (milliseconds)

avatar
New Member

Hello,

I'm currently converting csv files into avro and I'd like to store the date time stamps as unix (milliseconds). Is there a way to go about this in NiFi?

Thanks.

1 ACCEPTED SOLUTION

avatar
Rising Star

@Harry Yuen your going to want to use "toNumber" in the NiFi expression Language. More information can be found here: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#tonumber

Basically on your DateTime you'll want to cast:

${now():toNumber()}

This will output the UnixEpoch time.

View solution in original post

2 REPLIES 2

avatar
Rising Star

@Harry Yuen your going to want to use "toNumber" in the NiFi expression Language. More information can be found here: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#tonumber

Basically on your DateTime you'll want to cast:

${now():toNumber()}

This will output the UnixEpoch time.

avatar
Super Guru

@Harry Yuen

@Devin Pinkston is correct. If you were to convert a date string, you would have had to add also the input date format, for example:

${now():toNumber():format('yyyy-MM-dd')}