Example usage for org.springframework.core.convert.converter ConverterRegistry addConverter

List of usage examples for org.springframework.core.convert.converter ConverterRegistry addConverter

Introduction

In this page you can find the example usage for org.springframework.core.convert.converter ConverterRegistry addConverter.

Prototype

<S, T> void addConverter(Class<S> sourceType, Class<T> targetType, Converter<? super S, ? extends T> converter);

Source Link

Document

Add a plain converter to this registry.

Usage

From source file:org.springframework.core.convert.converter.ExtendedConverterRegistryUtils.java

public static final void addConverters(ConverterRegistry registry,
        Collection<? extends ExtendedConverter<?, ?>> converters) {
    if (ExtendedCollectionUtils.isEmpty(converters)) {
        return;/*from w w  w. jav  a 2s. c om*/
    }

    for (ExtendedConverter<?, ?> c : converters) {
        registry.addConverter(c.getSourceType(), c.getTargetType(), c);
    }
}

From source file:org.springframework.format.datetime.ExtendedDateFormatterRegistrar.java

public static void addExtendedDateConverters(ConverterRegistry registry) {
    ExtendedConverterRegistryUtils.addConverters(registry, EXTRA_DATE_CONVERTERS);
    registry.addConverter(Period.class, String.class, ExtendedObjectToStringConverter.INSTANCE);
}