That note about not using type conversion for dates probably has to do with the fact that dates can be formatted and so parsed using different patterns depending on different locales. If your code uses a fixed pattern such as yours, I suppose you can ignore this.
So based on that, you can simply use a Date property in your action or a nested model object and annotate it with a @TypeConversion with a custom type converter. Cheers, GB akinss wrote: > > 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. > > -- View this message in context: http://www.nabble.com/S2-Textfield-tag-date-formatting-tp16600189p16617646.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]