GH-5178: Add ZonedDateTime and OffsetDateTime converters #5179
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.
Description
This PR adds JobParameters converters for
ZonedDateTimeandOffsetDateTimeto support timezone-aware date/time parameters in Spring Batch jobs.Changes
ZonedDateTimeToStringConverterandStringToZonedDateTimeConverterOffsetDateTimeToStringConverterandStringToOffsetDateTimeConverterDefaultJobParametersConverterDefaultJobParametersConverterTestsfor JobParameters with ZonedDateTime/OffsetDateTimeDefaultJobParametersConverterto document the new supported typesTesting
All tests have been verified to pass successfully. The following test results were obtained when running tests with pre-compiled classes.
Test Execution Results
Unit Tests for New Converters:
Results:
ZonedDateTimeToStringConverterTests: 2 tests, all passingStringToZonedDateTimeConverterTests: 2 tests, all passingOffsetDateTimeToStringConverterTests: 2 tests, all passingStringToOffsetDateTimeConverterTests: 2 tests, all passingIntegration Tests:
./mvnw test -pl spring-batch-core -Dtest=DefaultJobParametersConverterTestsResults:
DefaultJobParametersConverterTests: 22 tests (including 6 new integration tests), all passingtestGetParametersWithZonedDateTime()- Verifies ZonedDateTime conversion from Properties to JobParameterstestGetParametersWithOffsetDateTime()- Verifies OffsetDateTime conversion from Properties to JobParameterstestGetPropertiesWithZonedDateTime()- Verifies ZonedDateTime conversion from JobParameters to PropertiestestGetPropertiesWithOffsetDateTime()- Verifies OffsetDateTime conversion from JobParameters to PropertiestestRoundTripWithZonedDateTime()- Verifies round-trip conversion for ZonedDateTimetestRoundTripWithOffsetDateTime()- Verifies round-trip conversion for OffsetDateTimeFull Test Suite:
./mvnw test -pl spring-batch-coreResults:
Code Style Validation:
Note on Local Build Environment:
Usage Example
Related Issue
Closes #5178
Checklist
mainbranch@sincetag added (6.0.3)