Lukasz Lenart created WW-5812:
---------------------------------
Summary: DateConverter silently misparses ISO yyyy-MM-dd dates
under lenient locale or global patterns
Key: WW-5812
URL: https://issues.apache.org/jira/browse/WW-5812
Project: Struts 2
Issue Type: Bug
Components: Core
Reporter: Lukasz Lenart
Fix For: 7.5.0
h2. Problem
{{input type="date"}} always submits {{yyyy-MM-dd}}. When {{DateConverter}}
converts that value to {{java.util.Date}}, it tries the formats in this order:
the global {{struts.date.format}} pattern, then the locale date-time and
SHORT/MEDIUM/LONG date formats, and only then ISO {{yyyy-MM-dd}}. All of these
are lenient {{SimpleDateFormat}}s, so an earlier pattern with {{-}} separators
accepts the ISO string and returns a wrong date. No conversion error is raised.
||Pattern source||Pattern||{{2026-10-24}} parses to||
|{{struts.date.format=dd-MM-yyyy}}|{{dd-MM-yyyy}}|18 Apr 0030|
|locale {{nl_NL}} SHORT|{{dd-MM-y}}|18 Apr 2030|
|{{en_US}}, {{en_GB}}, {{de_DE}}, {{pl_PL}}|{{/}} or {{.}} separators|fails,
falls through to ISO (correct)|
This already affects {{textfield type="date"}} bound to a {{java.util.Date}}
property, and it will affect {{datetextfield}} in the html5 theme (WW-5778).
h2. Proposal
When the submitted string matches the ISO local date (or date-time) shape
exactly, parse it as ISO before trying the global and locale patterns. Add
tests that cover the {{nl_NL}} locale and a {{dd-MM-yyyy}} global pattern, and
check that non-ISO input still goes through the existing order.
Related: WW-5778
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)