You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Malte (Jira)" <ji...@apache.org> on 2025/03/11 20:11:00 UTC
[jira] [Created] (NIFI-14356) Add missing YearMonth and Year queries to DateTimeFormatter
Malte created NIFI-14356:
----------------------------
Summary: Add missing YearMonth and Year queries to DateTimeFormatter
Key: NIFI-14356
URL: https://issues.apache.org/jira/browse/NIFI-14356
Project: Apache NiFi
Issue Type: Bug
Components: Core Framework
Affects Versions: 2.2.0, 2.1.0, 2.0.0
Environment: OS: Ubuntu 24.04
Reporter: Malte
Apache NiFi 2 has replaced [SimpleDateFormat|https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/SimpleDateFormat.html] with [DateTimeFormatter|https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/time/format/DateTimeFormatter.html] for the [date functions|https://nifi.apache.org/nifi-docs/expression-language-guide.html#dates] in the expression language. The [parseToInstant|https://github.com/apache/nifi/blob/fc04d49057d5208d70342c15ee1e18ea545b14aa/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java#L240C27-L240C41] method of the [FormatUtils|https://github.com/apache/nifi/blob/fc04d49057d5208d70342c15ee1e18ea545b14aa/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/FormatUtils.java#L35C14-L35C25] class which is used by the expression language only includes temporal queries for the types Instant, LocalDateTime, LocalDate and LocalTime. So that patterns like 'yyyy' or 'yyyyMM' will throw a DateTimeParseException (regardless of the date string). Actually the example ({_}${year:toDate('yyyy', 'GMT')}{_}) from the NiFi 2 [expression language documentation|https://nifi.apache.org/nifi-docs/expression-language-guide.html#todate] throws an exception.
I propose to add temporal queries for Year and YearMonth as well.
I will provide a PR for this minor change and link it here.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)