Scrivio Interview library
InternalsIntermediate6 min read · updated 12 November 2026

Explain how ConversionService, Converter, GenericConverter, Formatter and PropertyEditor relate, and which one Spring uses for @Value, MVC binding and configuration properties.

PropertyEditor is the older, stateful, String-based JavaBeans mechanism that BeanWrapper still uses as a fallback, while ConversionService is Spring's stateless, thread-safe type conversion system, extended through Converter, ConverterFactory and GenericConverter plug-ins. Formatter adds locale-aware printing and parsing on top, registered in a FormattingConversionService. @Value is converted by the bean factory's type converter, which uses a ConversionService if one is set, as Spring Boot does with ApplicationConversionService, and property editors otherwise; MVC data binding uses the web ConversionService; and Boot binds configuration properties with ApplicationConversionService plus any converters marked @ConfigurationPropertiesBinding.

Why this question is asked

Spring converts text into typed values all the time: a property "30s" becomes a Duration, a request parameter "42" becomes a Long, a header becomes an enum. Over the years it gained several mechanisms for this, and they coexist, which is why a converter that works for request parameters can be ignored for @ConfigurationProperties, or the other way round. Interviewers ask this internals question to see whether we have a clear map of which mechanism is used where. In this answer, we will recap the oldest mechanism, PropertyEditor, then the ConversionService and its plug-ins, then Formatter, and finally follow @Value, MVC binding and configuration properties to see which one each uses.

1PropertyEditor, the Original Mechanism

PropertyEditor comes from the JavaBeans specification in the JDK. It converts between a String and an object through two steps: we call setAsText("42"), and then getValue() returns the converted object. Because the editor holds the value between those two calls, it is stateful, and so it is not thread-safe; this is why Spring gives each BeanWrapper or data binder its own editor instances rather than sharing one across threads.

Spring's BeanWrapper, the class that sets bean properties during XML and annotation-driven configuration, was built on property editors, and it still registers default editors for common types such as Class, Resource, Locale and arrays. Custom editors can be registered per type, and @InitBinder methods in controllers register them for one controller. Today they are mostly a fallback, but they explain some old behaviour.

Java
PropertyEditor editor = new CustomNumberEditor(Integer.class, true);
editor.setAsText("42"); // the editor now holds the value
Integer n = (Integer) editor.getValue();
System.out.println(n); // 42

2ConversionService and Its Plug-ins

ConversionService was introduced in Spring 3 as a general, stateless type conversion system: convert(source, targetType) from any type to any type, safe to share between threads. It is assembled from plug-ins. A Converter<S, T> converts one source type to one target type. A ConverterFactory<S, R> produces converters for a whole hierarchy, such as String to any Enum subtype. A GenericConverter handles several type pairs and sees the full TypeDescriptor, including generics and annotations on the field, which is how collection and array conversions work; a ConditionalGenericConverter can also decide whether it applies.

Java
DefaultConversionService cs = new DefaultConversionService();
cs.addConverter(String.class, Money.class, Money::parse);
System.out.println(cs.convert("42", Integer.class)); // 42
System.out.println(cs.convert("a,b,c", List.class)); // [a, b, c] (a built-in GenericConverter)
System.out.println(cs.convert("12.50 EUR", Money.class)); // Money[12.50 EUR] (our Converter)

DefaultConversionService comes with dozens of built-in converters, for numbers, enums, collections, Optional and more. Spring Boot's ApplicationConversionService adds converters for Duration and DataSize text such as 30s and 10MB, and for delimited strings.

3Formatter and FormattingConversionService

A Formatter<T> is a Printer<T> plus a Parser<T>: print(value, locale) and parse(text, locale). The locale makes it suitable for values shown to people, where the format depends on the language, such as numbers with a decimal comma in German. Formatters are registered in a FormattingConversionService, which is a ConversionService that also accepts formatters and annotation-driven formatting, such as @DateTimeFormat(pattern = "dd.MM.yyyy") and @NumberFormat on fields. DefaultFormattingConversionService adds the standard date-time and number formatters.

Step throughThe conversion family from old to new
  1. Formatter (Printer + Parser)locale-aware text for UI and web binding
  2. FormattingConversionServicea ConversionService that also holds formatters
  3. ConversionServicestateless, any type to any type, thread-safe
  4. Converter, ConverterFactory, GenericConverterthe plug-ins it is built from
  5. PropertyEditorJavaBeans, stateful, String only, fallback in BeanWrapper

5 layers, from the top down. Step through them one at a time.

Higher layers build on lower ones; PropertyEditor stands beside them as the legacy path.

4Which Mechanism @Value Uses

A @Value("${app.timeout}") Duration timeout is resolved in two steps. The placeholder is replaced with the property's text, and then the bean factory's TypeConverter converts the text to the field type. That type converter delegates in a fixed order: a custom PropertyEditor registered for the type wins, then the bean factory's ConversionService if one has been set, and then the default property editors.

In a plain Spring application, a ConversionService is only set on the bean factory if we declare a bean named conversionService. Spring Boot sets ApplicationConversionService on the bean factory, which is why @Value("${app.timeout:30s}") Duration works in Boot but may fail in a plain Spring context without that bean.

Java
@Value("${app.timeout:30s}") Duration timeout;
// Spring Boot: PT30S (ApplicationConversionService converts "30s")
// Plain Spring without a conversionService bean: conversion may fail for "30s",
// because the default editors do not understand that format

5MVC Binding and Configuration Properties

Spring MVC binds request parameters, path variables, headers and form fields through a WebDataBinder that uses the MVC conversion service, a FormattingConversionService created by the MVC configuration. Converters and formatters added in WebMvcConfigurer.addFormatters go there, and Spring Boot adds every Converter, GenericConverter and Formatter bean to it. @InitBinder methods can still register property editors for one controller.

Boot binds @ConfigurationProperties with its Binder, which uses ApplicationConversionService and adds any converter beans annotated with @ConfigurationPropertiesBinding. That annotation exists because configuration binding happens very early, and Boot only includes converters we explicitly mark for it. A converter registered only through addFormatters is therefore invisible to configuration properties. A converter bean marked @ConfigurationPropertiesBinding, on the other hand, is still a Converter bean, so in Boot it is also added to the MVC conversion service.

Who converts what
Where the value comes fromMechanism usedHow to add our own
@Value field or parameterbean factory TypeConverter: editors, then ConversionServiceconversionService bean, or Boot's default
@RequestParam, @PathVariable, formsMVC FormattingConversionServiceaddFormatters, or a Converter bean in Boot
@ConfigurationPropertiesBoot Binder with ApplicationConversionService@ConfigurationPropertiesBinding converter bean
Bean properties in XMLBeanWrapper: editors, then ConversionServicecustom editor or conversionService bean

6Follow-up questions

Why is ConversionService preferred over PropertyEditor?

Because it is stateless and thread-safe, so one instance can be shared, it converts between any two types rather than only from String, and its plug-ins can see generics and annotations through TypeDescriptor. Property editors need a fresh instance per use and only handle text. New code should write converters or formatters.

When would you write a GenericConverter instead of a Converter?

When one conversion depends on the target's full type information, such as the element type of a collection or an annotation on the field, or when one class should handle several source and target pairs. For a single pair like String to Money, a Converter is simpler.

How can I convert a value manually with the same rules Spring uses?

Inject the ConversionService. In Spring Boot, the MVC one is available as mvcConversionService, and ApplicationConversionService.getSharedInstance() gives Boot's general one. Calling convert("30s", Duration.class) then follows exactly the same rules as binding.

7Conclusion

In this answer, we mapped Spring's conversion family. PropertyEditor is the old, stateful, String-based mechanism that BeanWrapper still uses as a fallback. ConversionService is the stateless system built from Converter, ConverterFactory and GenericConverter plug-ins, and Formatter adds locale-aware printing and parsing through FormattingConversionService. @Value uses the bean factory's type converter, which uses Boot's ApplicationConversionService when present, MVC binding uses the web conversion service, and configuration properties use ApplicationConversionService plus @ConfigurationPropertiesBinding converters.

What to say in the interviewAbout 80 seconds aloud

Open with

There are two generations. PropertyEditor is the JavaBeans mechanism: String only, and stateful, because you call setAsText and then getValue, so it is not thread-safe. Spring's BeanWrapper still registers default editors and uses them as a fallback.

Then, if they want more

The modern system is ConversionService, which is stateless, thread-safe and converts between any two types. It is built from plug-ins: a Converter for one source and target pair, a ConverterFactory for a hierarchy like String to any enum, and a GenericConverter when the conversion needs the full TypeDescriptor, like collection element types or field annotations.

Formatter sits on top: a Printer and Parser that receive the locale, registered in a FormattingConversionService, which is also where @DateTimeFormat and @NumberFormat come from.

As for who uses what: @Value goes through the bean factory's type converter, which tries custom editors, then the bean factory's ConversionService if one is set, then the default editors; Spring Boot sets ApplicationConversionService there, which is why 30s binds to a Duration in Boot.

MVC data binding uses the web FormattingConversionService, where addFormatters registrations and, in Boot, Converter and Formatter beans go. Configuration properties are bound by Boot's Binder with ApplicationConversionService, and custom converters must be marked @ConfigurationPropertiesBinding to be used there.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain how ConversionService, Converter, GenericConverter, Formatter and PropertyEditor...": https://scrivio-interview-library.netlify.app/spring-boot/spring-utilities/53052a0104/