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.

NiFi toDate

Solved Go to solution

NiFi toDate

New Contributor

I have an datetime attribute which looks something like this "2017-08-29T00:00:15.4945" which comes from a JSON file.

In my PutHDFS when I am trying to put files into a file structure I am trying to get Year/Month/Day.

My Directory: /data/events/${datetime:toDate("YYYY-MM-dd'T'HH:mm:ss.SSSS", "NZDT"):format("YYYY/MM/dd")}

This is nearly working but is putting 2017/01/01 but it should be 2017/08/29.

Thanks,

Brendan

1 ACCEPTED SOLUTION

Accepted Solutions

Re: NiFi toDate

Super Guru

Hi @Brendan Smith,
i'm using NiFi-1.1 and tried with the same datetime attribute as you have mentioned above.

The below expression is working perfectly fine for me.

/data/events/${date:toDate("yyyy-MM-dd'T'HH:mm:ss.SSSS"):format("yyyy-MM-dd")}

output:- drwxr-xr-x - nifi hdfs 0 2017-09-05 23:24 /data/events/2017-08-29

3 REPLIES 3

Re: NiFi toDate

Super Guru

Hi @Brendan Smith,
i'm using NiFi-1.1 and tried with the same datetime attribute as you have mentioned above.

The below expression is working perfectly fine for me.

/data/events/${date:toDate("yyyy-MM-dd'T'HH:mm:ss.SSSS"):format("yyyy-MM-dd")}

output:- drwxr-xr-x - nifi hdfs 0 2017-09-05 23:24 /data/events/2017-08-29

Highlighted

Re: NiFi toDate

New Contributor

Interesting I copied what you had and it now works :O.

It looks like the difference in lower case and upper case is the difference here.

Thanks!

Re: NiFi toDate

New Contributor

Hi i have to convert twitter date to solr type: https://lucene.apache.org/solr/guide/7_6/working-with-dates.html can someone help me?

Don't have an account?
Coming from Hortonworks? Activate your account here