From 118d093eaf8510fc1b0926975ece4240689d97ce Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 13 Sep 2016 21:37:44 +0200 Subject: [PATCH] Drop defensive Joda-Time 2.x check --- .../joda/JodaTimeFormatterRegistrar.java | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java index cb4af997ca..93e9ead87f 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java @@ -38,7 +38,6 @@ import org.springframework.format.FormatterRegistry; import org.springframework.format.Parser; import org.springframework.format.Printer; import org.springframework.format.annotation.DateTimeFormat.ISO; -import org.springframework.util.ClassUtils; /** * Configures Joda-Time's formatting system for use with Spring. @@ -62,14 +61,6 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar { private enum Type {DATE, TIME, DATE_TIME} - /** - * Strictly speaking, this should not be necessary since we formally require JodaTime 2.x. - * However, since Joda-Time formatters are being registered automatically, we defensively - * adapt to Joda-Time 1.x when encountered on the classpath. To be removed in Spring 5.0. - */ - private static final boolean jodaTime2Available = ClassUtils.isPresent( - "org.joda.time.YearMonth", JodaTimeFormatterRegistrar.class.getClassLoader()); - /** * User defined formatters. */ @@ -209,9 +200,8 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar { registry.addFormatterForFieldType(Period.class, new PeriodFormatter()); registry.addFormatterForFieldType(Duration.class, new DurationFormatter()); - if (jodaTime2Available) { - JodaTime2Delegate.registerAdditionalFormatters(registry); - } + registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter()); + registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter()); registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); } @@ -241,16 +231,4 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar { } } - - /** - * Inner class to avoid a hard dependency on Joda-Time 2.x. - */ - private static class JodaTime2Delegate { - - public static void registerAdditionalFormatters(FormatterRegistry registry) { - registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter()); - registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter()); - } - } - }