Kazuki Shimizu (@kazuki43zoo) opened SPR-14839 and commented

I hope to support the @DateTimeFormat annotation for Joda-Time's YearMonth, MonthDay, and Year types, analogous to the existing support for the corresponding JSR-310 types.

For example:

public class AccountForm {

    @DateTimeFormat(pattern="MM/uuuu")
    private YearMonth expirationMonth;

    @DateTimeFormat(pattern="M/d")
    private MonthDay dayOfBirth;

    // ...
}

Affects: 4.3.3

Issue Links: - #18095 Conversion support for java.time.YearMonth (as well as MonthDay) - #20016 ScheduledAnnotationBeanPostProcessor does not support Duration syntax - #20983 Missing java.time.Year Formatter

Referenced from: pull request https://github.com/spring-projects/spring-framework/pull/1215

Comment From: spring-projects-issues

Kazuki Shimizu commented

I've submitted PR. Please review.

Comment From: spring-projects-issues

Sam Brannen commented

Note that the PR currently does not include a YearFormatter.

Comment From: spring-projects-issues

Juergen Hoeller commented

Indeed, I'm repurposing this ticket a bit: primarily for JSR-310 where Year is also a topic, with Joda-Time as a secondary target.

Comment From: spring-projects-issues

Sam Brannen commented

But... you just introduced org.springframework.format.datetime.standard.YearFormatter in Spring 5.0.4 -- right? ;-)

Comment From: spring-projects-issues

Juergen Hoeller commented

Indeed but that ticket just covered parsing according to the default format, like we do for Period and Duration, without any declarative customization options. This ticket is about considering @DateTimeFormat custom pattern support for remaining types where this makes sense.

Comment From: spring-projects-issues

Sam Brannen commented

This ticket is about considering @DateTimeFormat custom pattern support for remaining types where this makes sense.

Indeed!

Thanks for pointing out the difference.

Comment From: ioxua

Any reason this issue is frozen?

Comment From: onacit

Also, any reason why this PR doesn't cover for java.time.Month with it's value not as an enum?

// for numeric value
@NotNull @DateTimeFormat(pattern = "M") @PathVariable(name = PATH_NAME_MONTH) final Month month
Failed to convert value of type 'java.lang.String' to required type 'java.time.Month';
    nested exception is org.springframework.core.convert.ConversionFailedException:
        Failed to convert from type [java.lang.String] to type [@javax.validation.constraints.NotNull @org.springfr
amework.format.annotation.DateTimeFormat @org.springframework.web.bind.annotation.PathVariable java.time.Month] for value '11'; nested exception is java.lang.IllegalArgumentException: No enum constant java.time.Month.11]

Comment From: snicoll

Closing in favor of PR #1215