Skip to content

Commit 118d093

Browse files
committed
Drop defensive Joda-Time 2.x check
1 parent d5c9cc6 commit 118d093

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.springframework.format.Parser;
3939
import org.springframework.format.Printer;
4040
import org.springframework.format.annotation.DateTimeFormat.ISO;
41-
import org.springframework.util.ClassUtils;
4241

4342
/**
4443
* Configures Joda-Time's formatting system for use with Spring.
@@ -62,14 +61,6 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
6261
private enum Type {DATE, TIME, DATE_TIME}
6362

6463

65-
/**
66-
* Strictly speaking, this should not be necessary since we formally require JodaTime 2.x.
67-
* However, since Joda-Time formatters are being registered automatically, we defensively
68-
* adapt to Joda-Time 1.x when encountered on the classpath. To be removed in Spring 5.0.
69-
*/
70-
private static final boolean jodaTime2Available = ClassUtils.isPresent(
71-
"org.joda.time.YearMonth", JodaTimeFormatterRegistrar.class.getClassLoader());
72-
7364
/**
7465
* User defined formatters.
7566
*/
@@ -209,9 +200,8 @@ public void registerFormatters(FormatterRegistry registry) {
209200

210201
registry.addFormatterForFieldType(Period.class, new PeriodFormatter());
211202
registry.addFormatterForFieldType(Duration.class, new DurationFormatter());
212-
if (jodaTime2Available) {
213-
JodaTime2Delegate.registerAdditionalFormatters(registry);
214-
}
203+
registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter());
204+
registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter());
215205

216206
registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
217207
}
@@ -241,16 +231,4 @@ private void addFormatterForFields(FormatterRegistry registry, Printer<?> printe
241231
}
242232
}
243233

244-
245-
/**
246-
* Inner class to avoid a hard dependency on Joda-Time 2.x.
247-
*/
248-
private static class JodaTime2Delegate {
249-
250-
public static void registerAdditionalFormatters(FormatterRegistry registry) {
251-
registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter());
252-
registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter());
253-
}
254-
}
255-
256234
}

0 commit comments

Comments
 (0)