NIFI-13579 Improve Timestamp Zone Offset Formatting and Parsing#9367
Closed
exceptionfactory wants to merge 2 commits intoapache:mainfrom
Closed
NIFI-13579 Improve Timestamp Zone Offset Formatting and Parsing#9367exceptionfactory wants to merge 2 commits intoapache:mainfrom
exceptionfactory wants to merge 2 commits intoapache:mainfrom
Conversation
- Improved Timestamp to String formatting to support patterns with zone offsets - Improved String to Timestamp parsing to support adjusted hours and minutes when zone offset is included
10 tasks
dan-s1
reviewed
Oct 16, 2024
.../main/java/org/apache/nifi/serialization/record/field/ObjectLocalDateTimeFieldConverter.java
Outdated
Show resolved
Hide resolved
Contributor
|
@exceptionfactory Changes look good and date is now formatted correctly in the submitter's case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NIFI-13579 Improves timestamp formatting and parsing for Record Readers and Record Writers as it relates to zone offset handling.
Following significant changes to move from
java.util.Datetojava.timeclasses for earlier 2.0.0 milestone releases, zone offset handling no longer worked in ways similar to earlier versions. When reading a timestamp string with a zone offset,LocalDateTime.parse()would ignore the zone offset and only consider the local date and time components. When writing a timestamp as a string, the converter would throw an exception due to theLocalDateTimeobject not having a value for offset seconds.The current set of changes adjusts Field Converter behavior to address these issues. When converting from a string to a timestamp, the parsing makes use of the DateTimeFormatter.parseBest() method to first try parsing with
ZonedDateTimeto handle zone offsets, and then parsing withLocalDateTime.When converting from a Timestamp or
LocalDateTimeto a string, the conversion creates aZonedDateTimefrom aLocalDateTimeusing the system default zone offset, avoiding unexpected zone offset conversion.Changes include new unit tests for these scenarios, as well as a new test for the
ValidateRecordProcessor with CSV Reader and Writer, exercising both sides of the conversion. These test methods get the current zone offset value from the JVM to ensure that tests work as expected regardless of the system timezone.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation