You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Amadei <da...@gmail.com> on 2007/02/24 20:58:07 UTC
[S2] doubt working with dates in brazilian format (dd/MM/yyyy)
Hi All,
I'm working with dates but I'm not able to convert dates to be
displayed automatically using the brazilian format (e. g. dd/MM/yyyy).
Also I'd like to know how to validate my dates using this format and
not the standard.
If somebody could point me to the docs where I can find some info
about those 2 items it would be great!
BTW: I`m not using the datetimepicker.
Thanks,
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] doubt working with dates in brazilian format (dd/MM/yyyy)
Posted by Dariusz Wojtas <dw...@gmail.com>.
Hi Daniel,
Maybe this will help.
You may create converters for any type.
Here is one I use for dates.
You also need to put 'xwork-conversion.properties' file in classpath,
something like:
java.util.Date=aaa.utils.typeconverter.DateConverter
And the converter class:
public class DateConverter extends DefaultTypeConverter {
public static final String DATE_FORMAT = "yyyy-MM-dd";
@Override
public Object convertValue(Map ctx, Object o, Class toType) {
if (toType == Date.class) {
String val = ((String[]) o)[0];
if (val != null && val.length() > 0) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
try {
return sdf.parse(val);
} catch (Exception e) {
System.out.println("Problem z konwersja daty: " + val + ", " +
e.getMessage());
}
}
} else if (toType == String.class) {
return o.toString();
}
return null;
}
}
Regards
Dariusz Wojtas
On 2/24/07, Daniel Amadei <da...@gmail.com> wrote:
> Hi All,
>
> I'm working with dates but I'm not able to convert dates to be
> displayed automatically using the brazilian format (e. g. dd/MM/yyyy).
> Also I'd like to know how to validate my dates using this format and
> not the standard.
>
> If somebody could point me to the docs where I can find some info
> about those 2 items it would be great!
>
> BTW: I`m not using the datetimepicker.
>
> Thanks,
> Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] doubt working with dates in brazilian format (dd/MM/yyyy)
Posted by Romu <ro...@gmail.com>.
if u got a form ( and any data) of type Date( java.util) then u can use:
1. <bean:write name="myForm" property="dateCreation" format="dd/MM/yyyy"/>
2. i guess it works as well with <html:text ..>
the solution 1 is working , it's extracted from one jsp i made 1 week ago :)
for the validation, well it should be in validation.xml (or u can code the
java script)
good luck
2007/2/25, Wesslan <fo...@wesslan.se>:
>
> I really like YYYY-MM-DD because that's the way we always write dates in
> Sweden... :)
>
> -----Original Message-----
> From: Stefan [mailto:stefan.riegel@telig.de]
> Sent: den 24 februari 2007 22:40
> To: Struts Users Mailing List
> Subject: Re: [S2] doubt working with dates in brazilian format
> (dd/MM/yyyy)
>
> Daniel Amadei schrieb:
> > Hi All,
> >
> > I'm working with dates but I'm not able to convert dates to be
> > displayed automatically using the brazilian format (e. g. dd/MM/yyyy).
> > Also I'd like to know how to validate my dates using this format and
> > not the standard.
> >
> > If somebody could point me to the docs where I can find some info
> > about those 2 items it would be great!
> >
> > BTW: I`m not using the datetimepicker.
> >
> > Thanks,
> > Daniel
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> Hi Daniel,
>
> not exactly what you asked. Just as an idea/opinion about international
> date
> formats:
> http://www.w3.org/QA/Tips/iso-date
>
> Regards
> Stefan
>
> --
>
> Stefan Riegel
> TELIG GmbH
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
RE: [S2] doubt working with dates in brazilian format (dd/MM/yyyy)
Posted by Wesslan <fo...@wesslan.se>.
I really like YYYY-MM-DD because that's the way we always write dates in
Sweden... :)
-----Original Message-----
From: Stefan [mailto:stefan.riegel@telig.de]
Sent: den 24 februari 2007 22:40
To: Struts Users Mailing List
Subject: Re: [S2] doubt working with dates in brazilian format (dd/MM/yyyy)
Daniel Amadei schrieb:
> Hi All,
>
> I'm working with dates but I'm not able to convert dates to be
> displayed automatically using the brazilian format (e. g. dd/MM/yyyy).
> Also I'd like to know how to validate my dates using this format and
> not the standard.
>
> If somebody could point me to the docs where I can find some info
> about those 2 items it would be great!
>
> BTW: I`m not using the datetimepicker.
>
> Thanks,
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Hi Daniel,
not exactly what you asked. Just as an idea/opinion about international date
formats:
http://www.w3.org/QA/Tips/iso-date
Regards
Stefan
--
Stefan Riegel
TELIG GmbH
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] doubt working with dates in brazilian format (dd/MM/yyyy)
Posted by Stefan <st...@telig.de>.
Daniel Amadei schrieb:
> Hi All,
>
> I'm working with dates but I'm not able to convert dates to be
> displayed automatically using the brazilian format (e. g. dd/MM/yyyy).
> Also I'd like to know how to validate my dates using this format and
> not the standard.
>
> If somebody could point me to the docs where I can find some info
> about those 2 items it would be great!
>
> BTW: I`m not using the datetimepicker.
>
> Thanks,
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Hi Daniel,
not exactly what you asked. Just as an idea/opinion about international
date formats:
http://www.w3.org/QA/Tips/iso-date
Regards
Stefan
--
Stefan Riegel
TELIG GmbH
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org