SPR-6529 - DateTimeFormatAnnotationFormatterFactory calls String.isEmpty(), which exists only in JDK1.6+

This commit is contained in:
Arjen Poutsma 2009-12-07 14:41:30 +00:00
parent 93abbd0ef7
commit 231c8337d2
2 changed files with 4 additions and 2 deletions

View File

@ -36,6 +36,7 @@ import org.springframework.format.Parser;
import org.springframework.format.Printer;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.util.StringUtils;
/**
* Formats fields annotated with the {@link DateTimeFormat} annotation.
@ -98,7 +99,7 @@ public final class DateTimeFormatAnnotationFormatterFactory implements Annotatio
}
private DateTimeFormatter configureDateTimeFormatterFrom(DateTimeFormat annotation) {
if (!annotation.pattern().isEmpty()) {
if (StringUtils.hasLength(annotation.pattern())) {
return forPattern(annotation.pattern());
}
else if (annotation.iso() != ISO.NONE) {

View File

@ -28,6 +28,7 @@ import org.springframework.format.Parser;
import org.springframework.format.Printer;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;
import org.springframework.util.StringUtils;
/**
* Formats fields annotated with the {@link NumberFormat} annotation.
@ -74,7 +75,7 @@ public final class NumberFormatAnnotationFormatterFactory implements AnnotationF
}
private Formatter<Number> configureFormatterFrom(NumberFormat annotation, Class<?> fieldType) {
if (!annotation.pattern().isEmpty()) {
if (StringUtils.hasLength(annotation.pattern())) {
return new NumberFormatter(annotation.pattern());
}
else {