Skip to content

Commit 231c833

Browse files
committed
SPR-6529 - DateTimeFormatAnnotationFormatterFactory calls String.isEmpty(), which exists only in JDK1.6+
1 parent 93abbd0 commit 231c833

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

org.springframework.context/src/main/java/org/springframework/format/datetime/joda/DateTimeFormatAnnotationFormatterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.format.Printer;
3737
import org.springframework.format.annotation.DateTimeFormat;
3838
import org.springframework.format.annotation.DateTimeFormat.ISO;
39+
import org.springframework.util.StringUtils;
3940

4041
/**
4142
* Formats fields annotated with the {@link DateTimeFormat} annotation.
@@ -98,7 +99,7 @@ private Set<Class<?>> createFieldTypes() {
9899
}
99100

100101
private DateTimeFormatter configureDateTimeFormatterFrom(DateTimeFormat annotation) {
101-
if (!annotation.pattern().isEmpty()) {
102+
if (StringUtils.hasLength(annotation.pattern())) {
102103
return forPattern(annotation.pattern());
103104
}
104105
else if (annotation.iso() != ISO.NONE) {

org.springframework.context/src/main/java/org/springframework/format/number/NumberFormatAnnotationFormatterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.format.Printer;
2929
import org.springframework.format.annotation.NumberFormat;
3030
import org.springframework.format.annotation.NumberFormat.Style;
31+
import org.springframework.util.StringUtils;
3132

3233
/**
3334
* Formats fields annotated with the {@link NumberFormat} annotation.
@@ -74,7 +75,7 @@ private Set<Class<?>> createFieldTypes() {
7475
}
7576

7677
private Formatter<Number> configureFormatterFrom(NumberFormat annotation, Class<?> fieldType) {
77-
if (!annotation.pattern().isEmpty()) {
78+
if (StringUtils.hasLength(annotation.pattern())) {
7879
return new NumberFormatter(annotation.pattern());
7980
}
8081
else {

0 commit comments

Comments
 (0)