Drop defensive Joda-Time 2.x check

This commit is contained in:
Juergen Hoeller 2016-09-13 21:37:44 +02:00
parent d5c9cc62f1
commit 118d093eaf
1 changed files with 2 additions and 24 deletions

View File

@ -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());
}
}
}