Hi
you should create your own ObjectStringConverter and set it in the
configuraton object like this:
BeanReader beanReader = new BeanReader();
beanReader.getBindingConfiguration().setObjectStringConverter(new
CustomObjectStringConverter());
public class CustomObjectStringConverter extends DefaultObjectStringConverter
{
private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
public String objectToString(Object objeto, Class clase, String
flavour, Context contexto)
{
if (objeto != null)
{
if (objeto instanceof Date)
{
return dateFormat.format((Date) objeto);
}
}
return super.objectToString(objeto, clase, flavour, contexto);
}
public Object stringToObject(String dato, Class clase, String
flavour, Context contexto)
{
try
{
if (Date.class.equals(clase))
{
return dateFormat.parse(dato.trim());
}
}
catch (Exception e)
{
System.err.println("Error de parseo parseando a " +
clase + "el
string=" + dato);
return null;
}
return super.stringToObject(dato, clase, flavour, contexto);
}
}
I hope this will be useful for you
PS: excuse my terrible english
On 4/7/06, Nikolay Jordanov <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Can anyone point me to a simple example of how to get Betwixt to convert
> Date format using ConvertUtils?
> There is some information in
> http://jakarta.apache.org/commons/betwixt/betwixt-0.5/guide/binding.html
> which refers to a ConvertUtilsObjectStringConverter - but it is not
> obvious how to proceed, and a search of the web reveals no examples. A
> simple Hello World example of how date conversion is implemented would
> be very useful.
>
> Many thanks,
> Nik
>
>
>
>
> This message should be regarded as confidential. If you have received this
> email in error please notify the sender and destroy it immediately.
> Statements of intent shall only become binding when confirmed in hard copy by
> an authorised signatory. The contents of this email may relate to dealings
> with other companies within the Detica Group plc group of companies.
>
> Detica Limited is registered in England under No: 1337451.
>
> Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.
>
>
>
>
--
To Iterate is Human, to Recurse, Divine
- James O. Coplien, Bell Labs
-------------------------------------
<EPI/> - Deploying ideas
-------------------------------------
Ing. Diego H. Mornacco
Desarrollador
Epidata Consulting
MaipĂș 521 1er piso Of. A
Ofi: 5031 0060 / 61
Cel: 15-5884-0040
www.epidataconsulting.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]