Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Problem with transform date to long in nifi

avatar
Explorer

Hi guys,

I have some problems with transform date from string to long in NIFI. I have date like this: "02-01-1968|" and I need to transform this to long. i am using UpdateAttribte Processor to format it to number like this: ${my_date:toDate("dd-MM-yyyy","GMT"):toNumber()})} but I have result like this: "my_date" : -63072000000 .Does anyone know how to solve this better? 

3 REPLIES 3

avatar

Hi @MWM ,

The reason you are getting negative value is because the minimum date in epoch is "January 1st, 1970"  which corresponds to "0".  It turns out you can still convert the negative value back to date using the following expression:

${my_date:toDate():format("dd-MM-yyyy")}

If that helps please accept solution.

Thanks

 

avatar
Explorer

Hi @SAMSAL , Yes i can convert negative value back but i need to send this date as long to other system and this is my problem with converting this date to long in nifi using toNumber() because my value is negative 

avatar

Is the problem that the other system doesnt take negative values?