Close

Spring - Built-in converter List

[Last Updated: Oct 17, 2022]

Spring comes with predefined converters.

The built-in converters are not public, so we cannot find them in API docs. To know what types can be converted by default please use your IDE to view hierarchy of Converter interface.

Following code list all converters defined in Spring core:

package com.logicbig.example;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import java.util.Set;

public class SpringBuiltInConvertersFinder {
  public static void main(String[] args) {
      ClassPathScanningCandidateComponentProvider provider =
              new ClassPathScanningCandidateComponentProvider(false);
      provider.addIncludeFilter(new AssignableTypeFilter(Converter.class));
      Set<BeanDefinition> components = provider.findCandidateComponents("org/springframework");
      components.stream()
                .map(BeanDefinition::getBeanClassName)
                .forEach(System.out::println);
  }
}

Output

org.springframework.format.datetime.DateFormatterRegistrar$DateToCalendarConverter
org.springframework.format.datetime.DateFormatterRegistrar$CalendarToLongConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToCalendarConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToDateConverter
org.springframework.format.datetime.joda.JodaTimeConverters$LongToReadableInstantConverter
org.springframework.format.datetime.joda.JodaTimeConverters$CalendarToReadableInstantConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToMutableDateTimeConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToLocalDateTimeConverter
org.springframework.format.datetime.joda.JodaTimeConverters$LocalDateTimeToLocalTimeConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateToReadableInstantConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToInstantConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToDateMidnightConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToLocalDateConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToLongConverter
org.springframework.format.datetime.joda.JodaTimeConverters$DateTimeToLocalTimeConverter
org.springframework.format.datetime.joda.JodaTimeConverters$LocalDateTimeToLocalDateConverter
org.springframework.format.datetime.standard.DateTimeConverters$InstantToLongConverter
org.springframework.format.datetime.standard.DateTimeConverters$OffsetDateTimeToLocalTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$ZonedDateTimeToOffsetDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$CalendarToOffsetDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$ZonedDateTimeToLocalDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$CalendarToZonedDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$OffsetDateTimeToZonedDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$ZonedDateTimeToLocalDateConverter
org.springframework.format.datetime.standard.DateTimeConverters$LocalDateTimeToLocalTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$OffsetDateTimeToInstantConverter
org.springframework.format.datetime.standard.DateTimeConverters$OffsetDateTimeToLocalDateConverter
org.springframework.format.datetime.standard.DateTimeConverters$LocalDateTimeToLocalDateConverter
org.springframework.format.datetime.standard.DateTimeConverters$CalendarToLocalDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$ZonedDateTimeToInstantConverter
org.springframework.format.datetime.standard.DateTimeConverters$CalendarToInstantConverter
org.springframework.format.datetime.standard.DateTimeConverters$OffsetDateTimeToLocalDateTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$CalendarToLocalTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$ZonedDateTimeToLocalTimeConverter
org.springframework.format.datetime.standard.DateTimeConverters$CalendarToLocalDateConverter
org.springframework.format.datetime.standard.DateTimeConverters$LongToInstantConverter
org.springframework.format.datetime.DateFormatterRegistrar$CalendarToDateConverter
org.springframework.format.datetime.DateFormatterRegistrar$DateToLongConverter
org.springframework.format.datetime.DateFormatterRegistrar$LongToDateConverter
org.springframework.format.datetime.DateFormatterRegistrar$LongToCalendarConverter
org.springframework.core.convert.support.PropertiesToStringConverter
org.springframework.core.convert.support.StringToUUIDConverter
org.springframework.core.convert.support.StringToNumberConverterFactory$StringToNumber
org.springframework.core.convert.support.ZoneIdToTimeZoneConverter
org.springframework.core.convert.support.NumberToNumberConverterFactory$NumberToNumber
org.springframework.core.convert.support.StringToBooleanConverter
org.springframework.core.convert.support.StringToCharacterConverter
org.springframework.core.convert.support.ObjectToStringConverter
org.springframework.core.convert.support.EnumToStringConverter
org.springframework.core.convert.support.StringToCharsetConverter
org.springframework.core.convert.support.EnumToIntegerConverter
org.springframework.core.convert.support.StringToCurrencyConverter
org.springframework.core.convert.support.NumberToCharacterConverter
org.springframework.core.convert.support.ZonedDateTimeToCalendarConverter
org.springframework.core.convert.support.StringToLocaleConverter
org.springframework.core.convert.support.CharacterToNumberFactory$CharacterToNumber
org.springframework.core.convert.support.StringToPropertiesConverter
org.springframework.core.convert.support.StringToTimeZoneConverter
org.springframework.core.convert.converter.ConvertingComparator$ConversionServiceConverter
org.springframework.core.serializer.support.SerializingConverter
org.springframework.core.serializer.support.DeserializingConverter

Converters registered with DefaultConversionService

DefaultConversionService doesn't provide some public methods to see what Converters are registered by default, but we can use reflection to find that out:

package com.logicbig.example;

import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import java.lang.reflect.Field;

public class ConvertersRegisteredFinder {

  public static void main(String[] args) throws Exception {
      DefaultConversionService service = new DefaultConversionService();
      Field converters = GenericConversionService.class.getDeclaredField("converters");
      converters.setAccessible(true);
      Object o = converters.get(service);
      System.out.println(o.toString().replaceAll("@.+\n", "\n"));
  }
}

Output

ConversionService converters =
java.lang.Boolean -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
java.lang.Character -> java.lang.Number : org.springframework.core.convert.support.CharacterToNumberFactory
java.lang.Character -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
java.lang.Enum -> java.lang.Integer : org.springframework.core.convert.support.EnumToIntegerConverter
java.lang.Enum -> java.lang.String : org.springframework.core.convert.support.EnumToStringConverter
java.lang.Integer -> java.lang.Enum : org.springframework.core.convert.support.IntegerToEnumConverterFactory
java.lang.Number -> java.lang.Character : org.springframework.core.convert.support.NumberToCharacterConverter
java.lang.Number -> java.lang.Number : org.springframework.core.convert.support.NumberToNumberConverterFactory
java.lang.Number -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
java.lang.String -> java.lang.Boolean : org.springframework.core.convert.support.StringToBooleanConverter
java.lang.String -> java.lang.Character : org.springframework.core.convert.support.StringToCharacterConverter
java.lang.String -> java.lang.Enum : org.springframework.core.convert.support.StringToEnumConverterFactory
java.lang.String -> java.lang.Number : org.springframework.core.convert.support.StringToNumberConverterFactory
java.lang.String -> java.nio.charset.Charset : org.springframework.core.convert.support.StringToCharsetConverter
java.lang.String -> java.util.Currency : org.springframework.core.convert.support.StringToCurrencyConverter
java.lang.String -> java.util.Locale : org.springframework.core.convert.support.StringToLocaleConverter
java.lang.String -> java.util.Properties : org.springframework.core.convert.support.StringToPropertiesConverter
java.lang.String -> java.util.TimeZone : org.springframework.core.convert.support.StringToTimeZoneConverter
java.lang.String -> java.util.UUID : org.springframework.core.convert.support.StringToUUIDConverter
java.nio.charset.Charset -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
java.time.ZoneId -> java.util.TimeZone : org.springframework.core.convert.support.ZoneIdToTimeZoneConverter
java.time.ZonedDateTime -> java.util.Calendar : org.springframework.core.convert.support.ZonedDateTimeToCalendarConverter
java.util.Currency -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
java.util.Locale -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
java.util.Properties -> java.lang.String : org.springframework.core.convert.support.PropertiesToStringConverter
java.util.UUID -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter
org.springframework.core.convert.support.ArrayToArrayConverter
org.springframework.core.convert.support.ArrayToCollectionConverter
org.springframework.core.convert.support.ArrayToObjectConverter
org.springframework.core.convert.support.ArrayToStringConverter
org.springframework.core.convert.support.ByteBufferConverter
org.springframework.core.convert.support.ByteBufferConverter
org.springframework.core.convert.support.ByteBufferConverter
org.springframework.core.convert.support.ByteBufferConverter
org.springframework.core.convert.support.CollectionToArrayConverter
org.springframework.core.convert.support.CollectionToCollectionConverter
org.springframework.core.convert.support.CollectionToObjectConverter
org.springframework.core.convert.support.CollectionToStringConverter
org.springframework.core.convert.support.FallbackObjectToStringConverter
org.springframework.core.convert.support.IdToEntityConverter
org.springframework.core.convert.support.MapToMapConverter
org.springframework.core.convert.support.ObjectToArrayConverter
org.springframework.core.convert.support.ObjectToCollectionConverter
org.springframework.core.convert.support.ObjectToOptionalConverter
org.springframework.core.convert.support.StreamConverter
org.springframework.core.convert.support.StreamConverter
org.springframework.core.convert.support.StreamConverter
org.springframework.core.convert.support.StreamConverter
org.springframework.core.convert.support.StringToArrayConverter
org.springframework.core.convert.support.StringToCollectionConverter

Example Project

Dependencies and Technologies Used:

  • spring-context 5.3.23 (Spring Context)
     Version Compatibility: 4.0.7.RELEASE - 5.3.23 Version List
    ×

    Version compatibilities of spring-context with this example:

    • 4.0.7.RELEASE
    • 4.0.8.RELEASE
    • 4.0.9.RELEASE
    • 4.1.0.RELEASE
    • 4.1.1.RELEASE
    • 4.1.2.RELEASE
    • 4.1.3.RELEASE
    • 4.1.4.RELEASE
    • 4.1.5.RELEASE
    • 4.1.6.RELEASE
    • 4.1.7.RELEASE
    • 4.1.8.RELEASE
    • 4.1.9.RELEASE
    • 4.2.0.RELEASE
    • 4.2.1.RELEASE
    • 4.2.2.RELEASE
    • 4.2.3.RELEASE
    • 4.2.4.RELEASE
    • 4.2.5.RELEASE
    • 4.2.6.RELEASE
    • 4.2.7.RELEASE
    • 4.2.8.RELEASE
    • 4.2.9.RELEASE
    • 4.3.0.RELEASE
    • 4.3.1.RELEASE
    • 4.3.2.RELEASE
    • 4.3.3.RELEASE
    • 4.3.4.RELEASE
    • 4.3.5.RELEASE
    • 4.3.6.RELEASE
    • 4.3.7.RELEASE
    • 4.3.8.RELEASE
    • 4.3.9.RELEASE
    • 4.3.10.RELEASE
    • 4.3.11.RELEASE
    • 4.3.12.RELEASE
    • 4.3.13.RELEASE
    • 4.3.14.RELEASE
    • 4.3.15.RELEASE
    • 4.3.16.RELEASE
    • 4.3.17.RELEASE
    • 4.3.18.RELEASE
    • 4.3.19.RELEASE
    • 4.3.20.RELEASE
    • 4.3.21.RELEASE
    • 4.3.22.RELEASE
    • 4.3.23.RELEASE
    • 4.3.24.RELEASE
    • 4.3.25.RELEASE
    • 4.3.26.RELEASE
    • 4.3.27.RELEASE
    • 4.3.28.RELEASE
    • 4.3.29.RELEASE
    • 4.3.30.RELEASE
    • 5.0.0.RELEASE
    • 5.0.1.RELEASE
    • 5.0.2.RELEASE
    • 5.0.3.RELEASE
    • 5.0.4.RELEASE
    • 5.0.5.RELEASE
    • 5.0.6.RELEASE
    • 5.0.7.RELEASE
    • 5.0.8.RELEASE
    • 5.0.9.RELEASE
    • 5.0.10.RELEASE
    • 5.0.11.RELEASE
    • 5.0.12.RELEASE
    • 5.0.13.RELEASE
    • 5.0.14.RELEASE
    • 5.0.15.RELEASE
    • 5.0.16.RELEASE
    • 5.0.17.RELEASE
    • 5.0.18.RELEASE
    • 5.0.19.RELEASE
    • 5.0.20.RELEASE
    • 5.1.0.RELEASE
    • 5.1.1.RELEASE
    • 5.1.2.RELEASE
    • 5.1.3.RELEASE
    • 5.1.4.RELEASE
    • 5.1.5.RELEASE
    • 5.1.6.RELEASE
    • 5.1.7.RELEASE
    • 5.1.8.RELEASE
    • 5.1.9.RELEASE
    • 5.1.10.RELEASE
    • 5.1.11.RELEASE
    • 5.1.12.RELEASE
    • 5.1.13.RELEASE
    • 5.1.14.RELEASE
    • 5.1.15.RELEASE
    • 5.1.16.RELEASE
    • 5.1.17.RELEASE
    • 5.1.18.RELEASE
    • 5.1.19.RELEASE
    • 5.1.20.RELEASE
    • 5.2.0.RELEASE
    • 5.2.1.RELEASE
    • 5.2.2.RELEASE
    • 5.2.3.RELEASE
    • 5.2.4.RELEASE
    • 5.2.5.RELEASE
    • 5.2.6.RELEASE
    • 5.2.7.RELEASE
    • 5.2.8.RELEASE
    • 5.2.9.RELEASE
    • 5.2.10.RELEASE
    • 5.2.11.RELEASE
    • 5.2.12.RELEASE
    • 5.2.13.RELEASE
    • 5.2.14.RELEASE
    • 5.2.15.RELEASE
    • 5.2.16.RELEASE
    • 5.2.17.RELEASE
    • 5.2.18.RELEASE
    • 5.2.19.RELEASE
    • 5.2.20.RELEASE
    • 5.2.21.RELEASE
    • 5.2.22.RELEASE
    • 5.3.0
    • 5.3.1
    • 5.3.2
    • 5.3.3
    • 5.3.4
    • 5.3.5
    • 5.3.6
    • 5.3.7
    • 5.3.8
    • 5.3.9
    • 5.3.10
    • 5.3.11
    • 5.3.12
    • 5.3.13
    • 5.3.14
    • 5.3.15
    • 5.3.16
    • 5.3.17
    • 5.3.18
    • 5.3.19
    • 5.3.20
    • 5.3.21
    • 5.3.22
    • 5.3.23

    Versions in green have been tested.

  • JDK 8
  • Maven 3.8.1

Spring - Finding built-in converters Select All Download
  • spring-built-in-converter-list
    • src
      • main
        • java
          • com
            • logicbig
              • example
                • SpringBuiltInConvertersFinder.java

    See Also