Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Convert date time to 24 hour format in NiFi

avatar
Explorer

I am trying to convert the following date format -> 8/6/2023 12:46 am to this format -> 2023-08-06 00:46:00.

I want to do this using NiFi. I have tried using the UpdateRecod processor for the same and used toDate() and format() for the above conversion. But it didn't give the desired results.

How can I achieve this using NiFi?

1 REPLY 1

avatar

@janvit04 The pattern you need is this:

 

${input_date:toDate("MM/dd/yyyy hh:mm:ss"):format("yyyy-MM-dd HH:mm:ss")}

I did this in a test which you can find here.  In this example I have UpdateAttribute with an input attribute called input_date and its string value is  "8/6/2023 12:46 am".   In next UpdateAttribute i do the toDate and format.    With this setup you may need to modify the format in toDate function to match your input string until it gets right format.  For example I thought it should be m/d/yyyy but i got right output using MM/dd/yyyy.