Skip to content

Accept all java.time type values when pattern and type co-exist - #5890

Draft
BalusC wants to merge 1 commit into
masterfrom
faces_issue_2211
Draft

Accept all java.time type values when pattern and type co-exist#5890
BalusC wants to merge 1 commit into
masterfrom
faces_issue_2211

Conversation

@BalusC

@BalusC BalusC commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Undraft only when jakartaee/faces#2221 is merged!


Companion to jakartaee/faces#2211 / jakartaee/faces#2221, which add instant, year, yearMonth and monthDay to the type attribute of DateTimeConverter.

ConvertDateTimeHandler.setAttributes only forwards type to the converter alongside a pattern when isJavaTimeType(type) holds, and that method tested the first character:

char c = type.charAt(0);
result = c == 'l' || c == 'o' || c == 'z';

That covers local*, offset* and zoned*, but silently drops the four new type values. The converter then keeps its default type="date" and takes the legacy SimpleDateFormat branch, which cannot handle a java.time value:

  • <f:convertDateTime type="monthDay" pattern="dd-MM" /> parses 30-07 into a java.util.Date of 1970-07-30, then fails with IllegalArgumentException: Cannot convert 7/29/70, 8:00 PM of type class java.util.Date to class java.time.MonthDay during Process Validations.
  • <f:convertDateTime type="instant" pattern="uuuu-MM-dd HH:mm:ss" /> fails with IllegalArgumentException: Cannot format given Object as a Date during Render Response.

Replaced the character check with an explicit set of the values listed in DateTimeConverter#setType, and inlined the now-trivial isJavaTimeType into its single call site.

Covered by Spec2211IT in jakartaee/faces#2221 (tck/faces50/converters), which fails on master and passes with this change. Verified locally: faces50/converters 31/31, faces23/datetime-converter 11/11, faces20/api/converter-validator green.

🤖 Generated with Claude Code (Opus 5)

ConvertDateTimeHandler only forwarded type to the converter alongside a
pattern when the type name started with 'l', 'o' or 'z', which covered
localDate/offsetTime/zonedDateTime and friends but silently dropped the
instant, year, yearMonth and monthDay types added in faces#2211. The
converter then kept its default type "date" and took the legacy
SimpleDateFormat path, which fails on a java.time value.

Replaced by an explicit set of the type values listed in
DateTimeConverter#setType.

See jakartaee/faces#2211

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@BalusC
BalusC marked this pull request as draft July 31, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant