I'm trying to use a textfield tag for date input.  I need to format this in
the form dd/MM/yyyy HH:mm:ss

The teaxtfield tag formats the date to a Locale based format
DateFormat.SHORT  via XWorkBasicConverter.  For my locale this turns out to
be dd/MM/yy. This is not the format I want.

<s:textfield  cssClass="field" key="filter.dateTimeStart"
name="filter.dateTimeStart"/>

DateTimePicker wont allow you to apply a style class to the input field so
it wont format.  Bug has been reported in Struts JIRA (WW-1778) and a fix
made.  Need to wait for Struts 2.1 before this will work so I can't use
this.

Using the value parameter and a date tag won't work because this overwrites
the value entered.  If the user enters a value that can't be converted to a
date it isn't re-displayed, the field is displayed empty.

<s:textfield  cssClass="field" key="filter.dateTimeStart"
name="filter.dateTimeStart">
  <s:param name="value">
    <s:date name="filter.dateTimeStart" format="dd/MM/yyyy HH:mm:ss" />
  </s:param>
</s:textfield>

In the S2 guide for Type Conversion (
http://struts.apache.org/2.x/docs/type-conversion.html) it has a note saying
not to use Type Conversion for dates.

Does anyone know of a way to do this?


Thanks in advance.

Reply via email to