- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
NiFi Convert String to Date Attribute
- Labels:
-
Apache NiFi
Created ‎12-11-2020 08:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm new to NiFi and having an issue with a workflow. I created a MySQL query to pull in training course completions into a JSON RecordSetWriter format. When I view the queue contents, the "completed_on" attribute shows as a string {"name":"completed_on","type":["null","string"]} whereas it needs to be "datetime". The data appears as a string formatted like this. ("completed_on":"1605870000000")
How can I convert the attribute back to a date format so I can get the data to read in YYYY-MM-DD format?
Created ‎12-13-2020 10:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can do this with UpdateAttribute.
In my example:
Date_Time ==> ${YourUnixTimestamp:toDate():format('YYYY-MM-dd hh:mm:ss.SSS', 'UTC')}
YourDate_YYYY-MM-dd ==> ${YourUnixTimestamp:toDate():format('YYYY-MM-dd')}
You can check the result here: https://www.unixtimestamp.com/index.php
But you have to remove the last three digits of the value.
Hope this helps!
