diff --git a/org.springframework.context/src/main/java/org/springframework/ui/format/support/FormattingConversionServiceAdapter.java b/org.springframework.context/src/main/java/org/springframework/ui/format/support/FormattingConversionServiceAdapter.java index 006fe1b2b3c..4750024ad4d 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/format/support/FormattingConversionServiceAdapter.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/format/support/FormattingConversionServiceAdapter.java @@ -55,8 +55,8 @@ public class FormattingConversionServiceAdapter extends GenericConversionService } @Override - protected GenericConverter getConverter(Class sourceType, TypeDescriptor targetType) { - if (String.class.equals(sourceType)) { + protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) { + if (String.class.equals(sourceType.getType())) { Formatter formatter = this.formatterRegistry.getFormatter(targetType); if (formatter != null) { return new FormattingConverter(formatter); @@ -76,13 +76,18 @@ public class FormattingConversionServiceAdapter extends GenericConversionService this.formatter = formatter; } - public Object convert(Object source, TypeDescriptor targetType) { + public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) { + throw new UnsupportedOperationException("Should not be called"); + } + + public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { try { return this.formatter.parse((String) source, LocaleContextHolder.getLocale()); } catch (ParseException ex) { throw new IllegalArgumentException("Could not convert formatted value '" + source + "'", ex); } } + } } diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/support/MatchableGenericConverter.java b/org.springframework.core/src/main/java/org/springframework/core/convert/support/MatchableGenericConverter.java deleted file mode 100644 index 3898392541a..00000000000 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/support/MatchableGenericConverter.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.springframework.core.convert.support; - -import org.springframework.core.convert.TypeDescriptor; - -public interface MatchableGenericConverter extends GenericConverter { - - boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType); - -}