struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carl ballantyne <>
Subject s:textfield and date format as dd/MM/yyyy
Date Wed, 04 Nov 2009 14:43:31 GMT
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 " = {0,date,dd/MM/yyyy}" in the properties  
( 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 " = dd/MM/yyyy" to the  
properties file for my package.  
( 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?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message