Deprecate Joda time support

This commit deprecates the Joda time support and schedules it for
removal in 6.0.

Closes gh-25736
This commit is contained in:
Brian Clozel
2020-09-08 13:12:53 +02:00
parent 7dbb40ffa0
commit 078543ce67
15 changed files with 34 additions and 12 deletions

View File

@@ -42,7 +42,9 @@ import org.springframework.util.StringUtils;
* @see #setStyle
* @see #setIso
* @see DateTimeFormatterFactoryBean
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public class DateTimeFormatterFactory {
@Nullable

View File

@@ -33,7 +33,9 @@ import org.springframework.lang.Nullable;
* @see #setIso
* @see #setStyle
* @see DateTimeFormatterFactory
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
implements FactoryBean<DateTimeFormatter>, InitializingBean {

View File

@@ -29,7 +29,9 @@ import org.springframework.format.Parser;
*
* @author Keith Donald
* @since 3.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class DateTimeParser implements Parser<DateTime> {
private final DateTimeFormatter formatter;

View File

@@ -45,7 +45,9 @@ import org.springframework.util.StringUtils;
* @author Juergen Hoeller
* @since 3.0
* @see DateTimeFormat
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public class JodaDateTimeFormatAnnotationFormatterFactory extends EmbeddedValueResolutionSupport
implements AnnotationFormatterFactory<DateTimeFormat> {

View File

@@ -36,7 +36,9 @@ import org.springframework.lang.Nullable;
* @author Keith Donald
* @since 3.0
* @see JodaTimeContextHolder
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public class JodaTimeContext {
@Nullable

View File

@@ -31,7 +31,9 @@ import org.springframework.lang.Nullable;
* @author Juergen Hoeller
* @since 3.0
* @see org.springframework.context.i18n.LocaleContextHolder
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class JodaTimeContextHolder {
private static final ThreadLocal<JodaTimeContext> jodaTimeContextHolder =

View File

@@ -55,7 +55,9 @@ import org.springframework.format.annotation.DateTimeFormat.ISO;
* @see FormatterRegistrar#registerFormatters
* @see org.springframework.format.datetime.DateFormatterRegistrar
* @see DateTimeFormatterFactoryBean
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
private enum Type {DATE, TIME, DATE_TIME}

View File

@@ -30,7 +30,9 @@ import org.springframework.format.Parser;
*
* @author Juergen Hoeller
* @since 4.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class LocalDateParser implements Parser<LocalDate> {
private final DateTimeFormatter formatter;

View File

@@ -30,7 +30,9 @@ import org.springframework.format.Parser;
*
* @author Juergen Hoeller
* @since 4.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class LocalDateTimeParser implements Parser<LocalDateTime> {
private final DateTimeFormatter formatter;

View File

@@ -30,7 +30,9 @@ import org.springframework.format.Parser;
*
* @author Juergen Hoeller
* @since 4.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class LocalTimeParser implements Parser<LocalTime> {
private final DateTimeFormatter formatter;

View File

@@ -27,7 +27,9 @@ import org.springframework.format.Printer;
*
* @author Keith Donald
* @since 3.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class MillisecondInstantPrinter implements Printer<Long> {
private final DateTimeFormatter formatter;

View File

@@ -28,7 +28,9 @@ import org.springframework.format.Printer;
*
* @author Keith Donald
* @since 3.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class ReadableInstantPrinter implements Printer<ReadableInstant> {
private final DateTimeFormatter formatter;

View File

@@ -28,7 +28,9 @@ import org.springframework.format.Printer;
*
* @author Keith Donald
* @since 3.0
* @deprecated as of 5.3.0, scheduled for removal in 6.0.
*/
@Deprecated
public final class ReadablePartialPrinter implements Printer<ReadablePartial> {
private final DateTimeFormatter formatter;

View File

@@ -19,7 +19,6 @@ package org.springframework.format.support;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.datetime.DateFormatterRegistrar;
import org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar;
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
import org.springframework.format.number.money.CurrencyUnitFormatter;
@@ -57,7 +56,6 @@ public class DefaultFormattingConversionService extends FormattingConversionServ
jodaTimePresent = ClassUtils.isPresent("org.joda.time.YearMonth", classLoader);
}
/**
* Create a new {@code DefaultFormattingConversionService} with the set of
* {@linkplain DefaultConversionService#addDefaultConverters default converters} and
@@ -106,6 +104,7 @@ public class DefaultFormattingConversionService extends FormattingConversionServ
* depending on the presence of the corresponding API on the classpath.
* @param formatterRegistry the service to register default formatters with
*/
@SuppressWarnings("deprecation")
public static void addDefaultFormatters(FormatterRegistry formatterRegistry) {
// Default handling of number values
formatterRegistry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
@@ -124,7 +123,7 @@ public class DefaultFormattingConversionService extends FormattingConversionServ
if (jodaTimePresent) {
// handles Joda-specific types as well as Date, Calendar, Long
new JodaTimeFormatterRegistrar().registerFormatters(formatterRegistry);
new org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar().registerFormatters(formatterRegistry);
}
else {
// regular DateFormat-based Date, Calendar, Long converters

View File

@@ -1362,8 +1362,7 @@ The `format` subpackages provide several `Formatter` implementations as a conven
The `number` package provides `NumberStyleFormatter`, `CurrencyStyleFormatter`, and
`PercentStyleFormatter` to format `Number` objects that use a `java.text.NumberFormat`.
The `datetime` package provides a `DateFormatter` to format `java.util.Date` objects with
a `java.text.DateFormat`. The `datetime.joda` package provides comprehensive datetime
formatting support based on the https://www.joda.org/joda-time/[Joda-Time library].
a `java.text.DateFormat`.
The following `DateFormatter` is an example `Formatter` implementation:
@@ -1568,7 +1567,7 @@ example shows:
A portable format annotation API exists in the `org.springframework.format.annotation`
package. You can use `@NumberFormat` to format `Number` fields such as `Double` and
`Long`, and `@DateTimeFormat` to format `java.util.Date`, `java.util.Calendar`, `Long`
(for millisecond timestamps) as well as JSR-310 `java.time` and Joda-Time value types.
(for millisecond timestamps) as well as JSR-310 `java.time`.
The following example uses `@DateTimeFormat` to format a `java.util.Date` as an ISO Date
(yyyy-MM-dd):
@@ -1701,8 +1700,7 @@ To do that, ensure that Spring does not register default formatters. Instead, re
formatters manually with the help of:
* `org.springframework.format.datetime.standard.DateTimeFormatterRegistrar`
* `org.springframework.format.datetime.DateFormatterRegistrar`, or
`org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar` for Joda-Time.
* `org.springframework.format.datetime.DateFormatterRegistrar`
For example, the following Java configuration registers a global `yyyyMMdd` format:
@@ -1764,8 +1762,7 @@ For example, the following Java configuration registers a global `yyyyMMdd` form
----
If you prefer XML-based configuration, you can use a
`FormattingConversionServiceFactoryBean`. The following example shows how to do so (this time using Joda
Time):
`FormattingConversionServiceFactoryBean`. The following example shows how to do so:
[source,xml,indent=0,subs="verbatim,quotes"]
----
@@ -1785,9 +1782,9 @@ Time):
</property>
<property name="formatterRegistrars">
<set>
<bean class="org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar">
<bean class="org.springframework.format.datetime.standard.DateTimeFormatterRegistrar">
<property name="dateFormatter">
<bean class="org.springframework.format.datetime.joda.DateTimeFormatterFactoryBean">
<bean class="org.springframework.format.datetime.standard.DateTimeFormatterFactoryBean">
<property name="pattern" value="yyyyMMdd"/>
</bean>
</property>