diff --git a/spring-framework-reference/src/validation.xml b/spring-framework-reference/src/validation.xml index 0fae35b2dd7..3eb61ee0908 100644 --- a/spring-framework-reference/src/validation.xml +++ b/spring-framework-reference/src/validation.xml @@ -801,9 +801,9 @@ public class StringToInteger implements Converter { sourceType, Class targetType); - - T convert(Object source, Class targetType); + boolean canConvert(Class sourceType, Class targetType); + + T convert(Object source, Class targetType); }]]> @@ -839,7 +839,7 @@ public interface ConversionService { - + ]]> @@ -921,31 +921,31 @@ package org.springframework.ui.format.date; public final class DateFormatter implements Formatter { - private String pattern; + private String pattern; + + public DateFormatter(String pattern) { + this.pattern = pattern; + } + + public String format(Date date, Locale locale) { + if (date == null) { + return ""; + } + return getDateFormat(locale).format(date); + } - public DateFormatter(String pattern) { - this.pattern = pattern; - } + public Date parse(String formatted, Locale locale) throws ParseException { + if (formatted.length() == 0) { + return null; + } + return getDateFormat(locale).parse(formatted); + } - public String format(Date date, Locale locale) { - if (date == null) { - return ""; - } - return getDateFormat(locale).format(date); - } - - public Date parse(String formatted, Locale locale) throws ParseException { - if (formatted.length() == 0) { - return null; - } - return getDateFormat(locale).parse(formatted); - } - - protected DateFormat getDateFormat(Locale locale) { - DateFormat dateFormat = new SimpleDateFormat(this.pattern, locale); - dateFormat.setLenient(false); - return dateFormat; - } + protected DateFormat getDateFormat(Locale locale) { + DateFormat dateFormat = new SimpleDateFormat(this.pattern, locale); + dateFormat.setLenient(false); + return dateFormat; + } }]]> @@ -979,7 +979,7 @@ public class Money { package org.springframework.ui.format; public interface AnnotationFormatterFactory { - Formatter getFormatter(A annotation); + Formatter getFormatter(A annotation); } ]]> @@ -992,12 +992,11 @@ package example.format; public class DecimalAnnotationFormatterFactory implements AnnotationFormatterFactory { - Formatter getFormatter(DecimalFormat annotation) { - DecimalFormatter formatter = DecimalFormatter(); - formatter.setPattern(annotation.value()); - return formatter; - } - + Formatter getFormatter(DecimalFormat annotation) { + DecimalFormatter formatter = DecimalFormatter(); + formatter.setPattern(annotation.value()); + return formatter; + } } ]]> @@ -1010,7 +1009,7 @@ package example.app; public class MyModel { @DecimalFormat("#,###") - private BigDecimal decimal; + private BigDecimal decimal; } ]]> @@ -1031,9 +1030,9 @@ public class MyModel { type, Formatter targetFormatter); + void add(Class type, Formatter targetFormatter); - void add(AnnotationFormatterFactory factory); + void add(AnnotationFormatterFactory factory); }]]>