Lukasz Lenart created WW-5813:
---------------------------------
Summary: DateConverter silently drops the time when the date-time
separator does not match the locale pattern
Key: WW-5813
URL: https://issues.apache.org/jira/browse/WW-5813
Project: Struts 2
Issue Type: Bug
Components: Core
Reporter: Lukasz Lenart
When a {{java.util.Date}} (or {{java.sql.Timestamp}}) property receives a
date-time whose separator between date and time differs from the locale's
date-time pattern, {{DateConverter}} converts it to midnight of that date
instead of rejecting it.
h2. Example
On JDK 25 the {{nl-NL}} SHORT/MEDIUM date-time pattern is {{dd-MM-y, HH:mm:ss}}
(JDK 17/21: {{dd-MM-y HH:mm:ss}}, the comma came with newer CLDR data).
Submitting
{code}24-10-2026 10:15:30
{code}
to a {{Date}} property under {{nl-NL}} on JDK 25 yields {{2026-10-24
00:00:00}}. The time is lost without any conversion error. An invalid time is
accepted the same way: {{24-10-2026 25:00:00}} also becomes midnight.
h2. Cause
No date-time format matches the whole input, so the converter falls back to a
date-only format ({{dd-MM-y}}). {{SimpleDateFormat.parse(String)}} stops at the
end of the date and ignores the trailing text, so the strict re-parse succeeds
on the prefix.
This exists on {{main}} before WW-5812; WW-5812 only changed which format is
selected when one matches the whole input.
h2. Possible fix
Require the final parse to consume the whole input (a {{ParsePosition}} check,
as WW-5812's format selection already does), and throw
{{TypeConversionException}} otherwise.
This is a behaviour change: any input with trailing text after a valid date,
which converts today, would then be rejected. It should be called out in the
release notes.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)