Created 06-16-2016 09:13 AM
I need next day as attribute.
As I know, date manipulation by adding ms (e.g. ${now():toNumber():plus(86400000) ).
With this solution I have a problem with the daylight saving:
If date = "2016-10-29 12:00:00"
${date:toDate("yyyy-MM-dd HH:mm:ss"):toNumber():plus(86400000):format("yyyy-MM-dd HH:mm:ss")}
This code results: "2016-10-30 11:00:00"
I have built a pyhton solution, but I'm not realy happy with it:
import java.io from org.apache.commons.io import IOUtils from java.nio.charset import StandardCharsets from org.apache.nifi.processor.io import StreamCallback from datetime import datetime from datetime import timedelta flowFile = session.get() if (flowFile != None): inDate = flowFile.getAttribute('inputDate') outputDateName = flowFile.getAttribute('output date attribute name') unit = flowFile.getAttribute('python timedelta unit') quantity = int(flowFile.getAttribute('quantity')) pythonDateFormat = flowFile.getAttribute('python date format') kwargs = {unit: quantity } outputDt = (datetime.strptime(inDate, pythonDateFormat) + timedelta(**kwargs)).strftime(pythonDateFormat) flowFile = session.putAttribute(flowFile, outputDateName, outputDt) session.transfer(flowFile, REL_SUCCESS)
Exist another solution with the given Nifi Processors?
I'm using HDF 1.2.0.0.
Created 06-17-2016 12:29 AM
According to the Nifi documentation, the timezone is embedded in the date information. https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#types
What if you included the timezone in your input and parsed with 'Z' in the format?
Created 06-17-2016 12:29 AM
According to the Nifi documentation, the timezone is embedded in the date information. https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#types
What if you included the timezone in your input and parsed with 'Z' in the format?
Created 06-20-2016 01:22 PM
I received the same date (perhaps I did something wrong 🙂 ).
I solved the problem with the following UpdateAttribute:
${date:toDate("yyyy-MM-dd"):toNumber():plus(86400000):format("yyyy-MM-dd"):append(${date:toDate("yyyy-MM-dd HH:mm:ss"):toNumber():format(" HH:mm:ss")})}
It works, but I'm still not very happy with this solution.