[ 
https://issues.apache.org/jira/browse/WW-5810?focusedWorklogId=1049906&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1049906
 ]

ASF GitHub Bot logged work on WW-5810:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Oct/26 13:55
            Start Date: 24/Oct/26 13:55
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #2056:
URL: https://github.com/apache/struts/pull/2056

   Fixes [WW-5810](https://issues.apache.org/jira/browse/WW-5810)
   
   ## What
   
   `datetextfield` now works with `java.time` properties in both the html5 
theme and the JavaTemplates plugin.
   
   - **`DateConverter`** converts a `java.util.Date` *object* into `LocalDate`, 
`LocalDateTime` or `LocalTime` in the server's default time zone. Before, it 
returned the `Date` unchanged whatever the target type, so a `java.time` 
property could not bind. This is the value `DateTextFieldInterceptor` binds, so 
the interceptor itself is unchanged. `Date` targets keep the existing 
behaviour. The instant is read via `getTime()`, because 
`java.sql.Date.toInstant()` throws.
   - **JavaTemplates `DateTextFieldHandler`** no longer casts `nameValue` to 
`Date` (a `ClassCastException` for any `java.time` value). It formats 
`java.time` values per field with `DateTimeFormatter`; a field the type does 
not have, such as `HH` on a `LocalDate`, renders empty.
   - **html5 theme**: `LocalDate` already rendered as ISO through `toString()`; 
now pinned by a test. A value with a time part (`LocalDateTime`, 
`ZonedDateTime`, `OffsetDateTime`) renders its date part instead of 
`2026-10-24T10:15`, which the browser rejects and shows as an empty field.
   
   ## Scope decisions
   
   - JavaTemplates supports `LocalDate`, `LocalDateTime` and `LocalTime`, the 
three `DateConverter` already accepts from strings. 
`ZonedDateTime`/`OffsetDateTime` are out: a split-field form has no zone or 
offset to submit.
   - html5 supports `LocalDate`. Binding a date-only input back into a 
time-bearing property still fails conversion; the docs point to `textfield 
type="datetime-local"` for those.
   - Binding is fixed in the converter rather than by making the interceptor 
emit an ISO string, so existing `Date` bindings don't move onto the 
string-parsing path (see 
[WW-5812](https://issues.apache.org/jira/browse/WW-5812)).
   
   ## Tests
   
   - `DateConverterTest`: `Date` and `java.sql.Date` into each `java.time` 
type; `Date` → `Date` unchanged.
   - `DateTextFieldInterceptorTest#testBindsToALocalDateProperty`: split fields 
→ interceptor → value stack → `LocalDate` property.
   - html5 `DateTextFieldTest`: `LocalDate` as ISO, date part of a 
`LocalDateTime`.
   - JavaTemplates `DateTextFieldTest`: `Date`, `LocalDate`, `LocalDateTime`, 
`LocalTime`, and an empty time field on a `LocalDate`.
   - Full suites green: core 3561, JavaTemplates 88.
   
   Site docs: apache/struts-site PR to follow.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1049906)
    Remaining Estimate: 0h
            Time Spent: 10m

> Support java.time types in the datetextfield tag
> ------------------------------------------------
>
>                 Key: WW-5810
>                 URL: https://issues.apache.org/jira/browse/WW-5810
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Tags
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.5.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> h2. Problem
> {{datetextfield}} only works with {{java.util.Date}} properties:
> * The JavaTemplates {{DateTextFieldHandler}} casts the value straight to 
> {{java.util.Date}}, so a {{LocalDate}} property fails with a 
> {{ClassCastException}}
> * {{DateTextFieldInterceptor}} reassembles the split fields with 
> {{SimpleDateFormat}} and always sets a {{java.util.Date}}
> * The html5 template added in WW-5778 renders the ISO {{yyyy-MM-dd}} value 
> from {{java.util.Date}} only
> {{input type="date"}} maps naturally to {{java.time.LocalDate}}, which is the 
> type most applications now use for a date without a time.
> h2. Proposal
> Support {{java.time}} property types (at least {{LocalDate}}) in 
> {{datetextfield}}:
> * html5 theme: render the ISO {{yyyy-MM-dd}} value for {{LocalDate}} (and 
> define the behaviour for {{LocalDateTime}} / {{ZonedDateTime}} etc. — 
> truncate to the date, or reject)
> * JavaTemplates theme: format the split fields from {{java.time}} values and 
> have {{DateTextFieldInterceptor}} set the property's declared type
> * Tests for each supported type, and the tag reference updated to list them
> Related: WW-5778 (datetextfield in the html5 theme)



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to