[ 
https://issues.apache.org/jira/browse/NIFI-15900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18085613#comment-18085613
 ] 

ASF subversion and git services commented on NIFI-15900:
--------------------------------------------------------

Commit d501315e0536ba7252b2d4bba585bb0330d306cd in nifi's branch 
refs/heads/main from Rakesh Kumar Singh
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=d501315e053 ]

NIFI-15900 Add optional timezone to plusDuration and minusDuration for 
DST-aware calendar arithmetic (#11296)

When adding or subtracting calendar units (days, weeks, months, years) across 
DST
boundaries, the result should preserve the wall-clock time rather than adding a
fixed number of seconds. Previously, both functions always used the JVM system
default timezone when converting the Date to a ZonedDateTime, which produced
incorrect results when the desired timezone differed from the system default.

Changes:
- Add optional timezone parameter to plusDuration and minusDuration functions
  e.g. plusDuration('1 day', 'America/New_York')
- Update ANTLR parser grammar to allow 1 or 2 arguments for these functions
- AbstractDateArithmeticEvaluator uses the provided timezone (or system default)
  when performing calendar arithmetic
- Add DST boundary test cases covering spring-forward and fall-back scenarios

> Incorporate DST changes in Expression language duration functions
> -----------------------------------------------------------------
>
>                 Key: NIFI-15900
>                 URL: https://issues.apache.org/jira/browse/NIFI-15900
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Core Framework, Extensions
>    Affects Versions: 2.9.0
>            Reporter: Mika Krieg
>            Assignee: Rakesh Kumar Singh
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> When adding durations to timestamps it is important for me to do so with 
> respect to the local timezone.
> This often requires the use of an ExecuteGroovyScript to use ZonedDateTime 
> functions instead of a simple UpdateAttribute.
> h2. Proposed solution
> So it would be helpful if parsed timestamps act like a ZonedDateTime object 
> with the specified timezone.
> {code:java}
> ${literal('2026-03-29 00:00:00'):toDate("yyyy-MM-dd HH:mm:ss", 
> "Europe/Vienna"):plusDuration("1 Days"):format("yyyy-MM-dd'T'HH:mm:ssXXX", 
> "Europe/Vienna")}{code}
> This expression currently evaluates to {{2026-03-30T01:00:00+02:00}}
> I would like it to evaluate to {{2026-03-30T00:00:00+02:00}} since the 
> locally dropped DST hour lies within this day-timeframe.
> h2. supported units
> The timezone sensitive durations would be:
>  * years
>  * weeks
>  * days



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to