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.

Converting Datetime to UnixEpoch time (milliseconds)

Solved Go to solution
Highlighted

Converting Datetime to UnixEpoch time (milliseconds)

New Contributor

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

Accepted Solutions

Re: Converting Datetime to UnixEpoch time (milliseconds)

Contributor

@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.

2 REPLIES 2

Re: Converting Datetime to UnixEpoch time (milliseconds)

Contributor

@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.

Re: Converting Datetime to UnixEpoch time (milliseconds)

@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')}
Don't have an account?
Coming from Hortonworks? Activate your account here