Support Questions

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

NiFi toDate

avatar
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

avatar
Master 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

View solution in original post

3 REPLIES 3

avatar
Master 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

avatar
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!

avatar
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?