Hi Mornak,

Thank you very much for your quick reply - this is exactly the example that we 
were looking for!
Thanks once again for your help and time.

Best regards,

Nikolay Jordanov

______________________________________________
Nikolay Jordanov - Consultant
t +44 (0) 1483 816325 | m +44 (0) 7738397002
a Detica | Surrey Research Park | Guildford | GU2 7YP | UK
______________________________________________
www.detica.com

-----Original Message-----
From: Mornak [mailto:[EMAIL PROTECTED] 
Sent: 07 April 2006 21:34
To: Jakarta Commons Users List
Subject: Re: Betwixt problem with Date formats

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.ht
> ml 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to