Skip to content

Replace custom converters with DefaultFormattingConversionService#5186

Open
scordio wants to merge 1 commit intospring-projects:mainfrom
scordio:gh-5178-DefaultFormattingConversionService
Open

Replace custom converters with DefaultFormattingConversionService#5186
scordio wants to merge 1 commit intospring-projects:mainfrom
scordio:gh-5178-DefaultFormattingConversionService

Conversation

@scordio
Copy link
Copy Markdown
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
@fmbenhassine
Copy link
Copy Markdown
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
Copy Markdown
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 🙂

@scordio scordio force-pushed the gh-5178-DefaultFormattingConversionService branch 2 times, most recently from aefe948 to 1014c1b Compare January 31, 2026 16:38
@scordio scordio force-pushed the gh-5178-DefaultFormattingConversionService branch from 1014c1b to 036ef58 Compare March 3, 2026 00:39
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