Hi All,

I have a Person object with a birthday attribute which is a Date. In the form I have a textfield to enter the value. I want the field to display the date in the format dd/MM/yyyy and the validation to apply using that format. However everything I am trying does not work.

I tried putting "format.date = {0,date,dd/MM/yyyy}" in the properties (http://struts.apache.org/2.1.8/docs/formatting-dates-and-numbers.html) as I am apparently supposed to but this does not display the date in the correct format via the s:date tag or the s:textfield tag and the validation does not work. Via the s:date I get "Nov 16, 1976 12:00:00 AM" and via s:textfield I get "11/16/76 12:00:00 AM.000". If I try and put a date in the format dd/MM/yyyy it tells me it is in an invalid format. It only accepts MM/dd/yyyy.

I also tried adding "struts.date.format = dd/MM/yyyy" to the properties file for my package. (http://struts.apache.org/2.1.8/docs/date.html). This seems to work a bit better. The date is displayed in the correct format via the s:date tag. However the s:textfield displays it as "11/16/76 12:00:00 AM.000". And the validation works the same as before, ie only accepts MM/dd/yyyy dates when I really want dd/MM/yyyy.

I am not using a custom Date Converter because the guide says not to use it to display i18n formatted dates. Do I need to resort to this?

It just seems I am doing something wrong as it should not be this difficult. How do you guys deal with converting date strings?

Cheers,
Carl.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to