Close

Spring Framework - ConversionService Examples

Spring Framework 

This examples uses DefaultConversionService, which is one of the ConversionService implementations. DefaultConversionService, by default, registers most of the appropriate Converters implementations.

package com.logicbig.example;


import org.springframework.core.convert.support.DefaultConversionService;

import java.util.Collection;
import java.util.Currency;

public class ConversionServiceExample {
public static void main (String[] args) {
DefaultConversionService service = new DefaultConversionService();

Currency convert = service.convert("USD", Currency.class);
System.out.println(convert);

Collection<String> list = service.convert("Deb, Mike, Kim",
Collection.class);
System.out.println(list);
}
}

Output

USD
[Deb, Mike, Kim]
Original Post




See Also