Richard Scott created NIFI-15658:
------------------------------------
Summary: Add datePlus and dateMinus functions to NiFi Expression
Language for date arithmetic
Key: NIFI-15658
URL: https://issues.apache.org/jira/browse/NIFI-15658
Project: Apache NiFi
Issue Type: Improvement
Affects Versions: 2.8.0
Reporter: Richard Scott
NiFi Expression Language provides {{toDate()}} for parsing values into a
{{{}Date{}}}, but there is no simple built-in way to then add or subtract time
from that {{{}Date{}}}.
Currently, users wanting to shift a parsed date must often convert the {{Date}}
back to a numeric value, perform arithmetic in milliseconds, and then convert
or format the result again. This is awkward and makes common date operations
harder to read and maintain.
For example, users should be able to write:
${myDate:toDate("dd-MM-yyyy"):datePlus("1 week"):format("dd-MM-yyyy")}
instead of relying on number-based date arithmetic after parsing.
Proposed new functions:
* {{datePlus(String duration)}}
* {{dateMinus(String duration)}}
Supported units:
* years
* months
* weeks
* days
* hours
* minutes
* seconds
The duration argument should be validated strictly, for example:
* valid: {{{}"1 day"{}}}, {{{}"2 weeks"{}}}, {{"3 months"}}
* invalid: {{{}"B weeks"{}}}, {{{}"1 dog"{}}}, {{"ten days"}}
Both functions should operate on and return {{Date}} values so they can be
chained naturally with existing date-related Expression Language functions such
as {{{}format(){}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)