38
38
import org .springframework .format .Parser ;
39
39
import org .springframework .format .Printer ;
40
40
import org .springframework .format .annotation .DateTimeFormat .ISO ;
41
- import org .springframework .util .ClassUtils ;
42
41
43
42
/**
44
43
* Configures Joda-Time's formatting system for use with Spring.
@@ -62,14 +61,6 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
62
61
private enum Type {DATE , TIME , DATE_TIME }
63
62
64
63
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
-
73
64
/**
74
65
* User defined formatters.
75
66
*/
@@ -209,9 +200,8 @@ public void registerFormatters(FormatterRegistry registry) {
209
200
210
201
registry .addFormatterForFieldType (Period .class , new PeriodFormatter ());
211
202
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 ());
215
205
216
206
registry .addFormatterForFieldAnnotation (new JodaDateTimeFormatAnnotationFormatterFactory ());
217
207
}
@@ -241,16 +231,4 @@ private void addFormatterForFields(FormatterRegistry registry, Printer<?> printe
241
231
}
242
232
}
243
233
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
-
256
234
}
0 commit comments