Skip to content

Commit 078543c

Browse files
committed
Deprecate Joda time support
This commit deprecates the Joda time support and schedules it for removal in 6.0. Closes gh-25736
1 parent 7dbb40f commit 078543c

15 files changed

+34
-12
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
* @see #setStyle
4343
* @see #setIso
4444
* @see DateTimeFormatterFactoryBean
45+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
4546
*/
47+
@Deprecated
4648
public class DateTimeFormatterFactory {
4749

4850
@Nullable

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
* @see #setIso
3434
* @see #setStyle
3535
* @see DateTimeFormatterFactory
36+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3637
*/
38+
@Deprecated
3739
public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
3840
implements FactoryBean<DateTimeFormatter>, InitializingBean {
3941

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
*
3030
* @author Keith Donald
3131
* @since 3.0
32+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3233
*/
34+
@Deprecated
3335
public final class DateTimeParser implements Parser<DateTime> {
3436

3537
private final DateTimeFormatter formatter;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
* @author Juergen Hoeller
4646
* @since 3.0
4747
* @see DateTimeFormat
48+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
4849
*/
50+
@Deprecated
4951
public class JodaDateTimeFormatAnnotationFormatterFactory extends EmbeddedValueResolutionSupport
5052
implements AnnotationFormatterFactory<DateTimeFormat> {
5153

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
* @author Keith Donald
3737
* @since 3.0
3838
* @see JodaTimeContextHolder
39+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3940
*/
41+
@Deprecated
4042
public class JodaTimeContext {
4143

4244
@Nullable

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
* @author Juergen Hoeller
3232
* @since 3.0
3333
* @see org.springframework.context.i18n.LocaleContextHolder
34+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3435
*/
36+
@Deprecated
3537
public final class JodaTimeContextHolder {
3638

3739
private static final ThreadLocal<JodaTimeContext> jodaTimeContextHolder =

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
* @see FormatterRegistrar#registerFormatters
5656
* @see org.springframework.format.datetime.DateFormatterRegistrar
5757
* @see DateTimeFormatterFactoryBean
58+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
5859
*/
60+
@Deprecated
5961
public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
6062

6163
private enum Type {DATE, TIME, DATE_TIME}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
*
3131
* @author Juergen Hoeller
3232
* @since 4.0
33+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3334
*/
35+
@Deprecated
3436
public final class LocalDateParser implements Parser<LocalDate> {
3537

3638
private final DateTimeFormatter formatter;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
*
3131
* @author Juergen Hoeller
3232
* @since 4.0
33+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3334
*/
35+
@Deprecated
3436
public final class LocalDateTimeParser implements Parser<LocalDateTime> {
3537

3638
private final DateTimeFormatter formatter;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
*
3131
* @author Juergen Hoeller
3232
* @since 4.0
33+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3334
*/
35+
@Deprecated
3436
public final class LocalTimeParser implements Parser<LocalTime> {
3537

3638
private final DateTimeFormatter formatter;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
*
2828
* @author Keith Donald
2929
* @since 3.0
30+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3031
*/
32+
@Deprecated
3133
public final class MillisecondInstantPrinter implements Printer<Long> {
3234

3335
private final DateTimeFormatter formatter;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
*
2929
* @author Keith Donald
3030
* @since 3.0
31+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3132
*/
33+
@Deprecated
3234
public final class ReadableInstantPrinter implements Printer<ReadableInstant> {
3335

3436
private final DateTimeFormatter formatter;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
*
2929
* @author Keith Donald
3030
* @since 3.0
31+
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
3132
*/
33+
@Deprecated
3234
public final class ReadablePartialPrinter implements Printer<ReadablePartial> {
3335

3436
private final DateTimeFormatter formatter;

spring-context/src/main/java/org/springframework/format/support/DefaultFormattingConversionService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.springframework.core.convert.support.DefaultConversionService;
2020
import org.springframework.format.FormatterRegistry;
2121
import org.springframework.format.datetime.DateFormatterRegistrar;
22-
import org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar;
2322
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
2423
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
2524
import org.springframework.format.number.money.CurrencyUnitFormatter;
@@ -57,7 +56,6 @@ public class DefaultFormattingConversionService extends FormattingConversionServ
5756
jodaTimePresent = ClassUtils.isPresent("org.joda.time.YearMonth", classLoader);
5857
}
5958

60-
6159
/**
6260
* Create a new {@code DefaultFormattingConversionService} with the set of
6361
* {@linkplain DefaultConversionService#addDefaultConverters default converters} and
@@ -106,6 +104,7 @@ public DefaultFormattingConversionService(
106104
* depending on the presence of the corresponding API on the classpath.
107105
* @param formatterRegistry the service to register default formatters with
108106
*/
107+
@SuppressWarnings("deprecation")
109108
public static void addDefaultFormatters(FormatterRegistry formatterRegistry) {
110109
// Default handling of number values
111110
formatterRegistry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
@@ -124,7 +123,7 @@ public static void addDefaultFormatters(FormatterRegistry formatterRegistry) {
124123

125124
if (jodaTimePresent) {
126125
// handles Joda-specific types as well as Date, Calendar, Long
127-
new JodaTimeFormatterRegistrar().registerFormatters(formatterRegistry);
126+
new org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar().registerFormatters(formatterRegistry);
128127
}
129128
else {
130129
// regular DateFormat-based Date, Calendar, Long converters

src/docs/asciidoc/core/core-validation.adoc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,7 @@ The `format` subpackages provide several `Formatter` implementations as a conven
13621362
The `number` package provides `NumberStyleFormatter`, `CurrencyStyleFormatter`, and
13631363
`PercentStyleFormatter` to format `Number` objects that use a `java.text.NumberFormat`.
13641364
The `datetime` package provides a `DateFormatter` to format `java.util.Date` objects with
1365-
a `java.text.DateFormat`. The `datetime.joda` package provides comprehensive datetime
1366-
formatting support based on the https://www.joda.org/joda-time/[Joda-Time library].
1365+
a `java.text.DateFormat`.
13671366

13681367
The following `DateFormatter` is an example `Formatter` implementation:
13691368

@@ -1568,7 +1567,7 @@ example shows:
15681567
A portable format annotation API exists in the `org.springframework.format.annotation`
15691568
package. You can use `@NumberFormat` to format `Number` fields such as `Double` and
15701569
`Long`, and `@DateTimeFormat` to format `java.util.Date`, `java.util.Calendar`, `Long`
1571-
(for millisecond timestamps) as well as JSR-310 `java.time` and Joda-Time value types.
1570+
(for millisecond timestamps) as well as JSR-310 `java.time`.
15721571

15731572
The following example uses `@DateTimeFormat` to format a `java.util.Date` as an ISO Date
15741573
(yyyy-MM-dd):
@@ -1701,8 +1700,7 @@ To do that, ensure that Spring does not register default formatters. Instead, re
17011700
formatters manually with the help of:
17021701

17031702
* `org.springframework.format.datetime.standard.DateTimeFormatterRegistrar`
1704-
* `org.springframework.format.datetime.DateFormatterRegistrar`, or
1705-
`org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar` for Joda-Time.
1703+
* `org.springframework.format.datetime.DateFormatterRegistrar`
17061704

17071705
For example, the following Java configuration registers a global `yyyyMMdd` format:
17081706

@@ -1764,8 +1762,7 @@ For example, the following Java configuration registers a global `yyyyMMdd` form
17641762
----
17651763

17661764
If you prefer XML-based configuration, you can use a
1767-
`FormattingConversionServiceFactoryBean`. The following example shows how to do so (this time using Joda
1768-
Time):
1765+
`FormattingConversionServiceFactoryBean`. The following example shows how to do so:
17691766

17701767
[source,xml,indent=0,subs="verbatim,quotes"]
17711768
----
@@ -1785,9 +1782,9 @@ Time):
17851782
</property>
17861783
<property name="formatterRegistrars">
17871784
<set>
1788-
<bean class="org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar">
1785+
<bean class="org.springframework.format.datetime.standard.DateTimeFormatterRegistrar">
17891786
<property name="dateFormatter">
1790-
<bean class="org.springframework.format.datetime.joda.DateTimeFormatterFactoryBean">
1787+
<bean class="org.springframework.format.datetime.standard.DateTimeFormatterFactoryBean">
17911788
<property name="pattern" value="yyyyMMdd"/>
17921789
</bean>
17931790
</property>

0 commit comments

Comments
 (0)