Skip to content

Conversation

@scordio
Copy link
Contributor

@scordio scordio commented Dec 28, 2025

This change replaces almost all existing custom converters with the Spring Framework's DefaultFormattingConversionService built-in features. The Date converters have been replaced with a custom formatter because the existing Spring Batch logic is incompatible with what the framework can offer.

DefaultFormattingConversionService also supports ZonedDateTime and OffsetDateTime out of the box; therefore, this PR also resolves #5178 and is an alternative to #5179.

@scordio

This comment was marked as outdated.

@scordio scordio force-pushed the gh-5178-DefaultFormattingConversionService branch from b8a8484 to 4aa4807 Compare December 29, 2025 08:55
@scordio scordio marked this pull request as ready for review December 29, 2025 08:59
Comment on lines +30 to +32
* @deprecated since 6.1 in favor of
* {@link ConversionServiceFactory#createConversionService()}. Scheduled for removal in
* 6.3 or later.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all existing converters are public, I proposed deprecating them for removal in 6.3. Let me know if I should make any adjustments to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how I would do it as well 👍

@fmbenhassine
Copy link
Contributor

Thank you for the PR! It's always better to leverage what we can from Spring Framework indeed. I will plan this for 6.1.

I am just not sure yet if we really need the ConversionServiceFactory with a static factory method, but I will come back to that in detail when I start working on 6.1.

@scordio
Copy link
Contributor Author

scordio commented Jan 13, 2026

I am just not sure yet if we really need the ConversionServiceFactory with a static factory method

I created that because the ConversionService is instantiated five times in the codebase in exactly the same way, so I thought it would be better to centralize it instead of repeating the following:

FormattingConversionService conversionService = new DefaultFormattingConversionService();
conversionService.addFormatterForFieldType(Date.class, new DateFormatter());

DateTimeFormatterRegistrar dateTimeFormatterRegistrar = new DateTimeFormatterRegistrar();
dateTimeFormatterRegistrar.setUseIsoFormat(true);
dateTimeFormatterRegistrar.registerFormatters(conversionService);

But I'm totally fine to inline it in those places or go in a different direction I haven't thought of, just let me know your preference 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ZonedDateTime and OffsetDateTime support to JobParametersConverter

2 participants