I almost understand it in the other way, haha...

Now things are clear!!!


 --- Bryce Fischer <[EMAIL PROTECTED]>
escreveu: 
> Leandro Melo wrote:
> 
> >I got one doubt in your code when used in a
> situation
> >that i mentioned (transforming data from action
> form
> >to dto).
> >When date comes from action form, they usually come
> in
> >Strings, but in your method you verify 
> >
> >value instanceof Date...
> >
> >This will never happen, as the value comes in
> String.
> >  
> >
> 
> Sorry, I had it backwards (thats what I get when I
> post in a hurry).  
> The example I sent was converting a Date property to
> String. To convert 
> other types to Date I have the following Converter:
> 
> public class DateConverter implements Converter{
>    public Object convert(Class type, Object value) {
>        if (value == null) {
>            return null;
>        } else if (type == Date.class) {
>            return convertToDate(type, value);
>        } else if (type == String.class) {
>            return convertToString(type, value);
>        }
> 
>        throw new ConversionException("Could not
> convert " +
>                                     
> value.getClass().getName() + " to " +
>                                     
> type.getName());
>    }
> 
>    protected Object convertToDate(Class type, Object
> value) {
>        if (value instanceof String) {
>            try {
> 
>                return df.parse((String) value);
>            } catch (Exception pe) {
>                throw new ConversionException("Error
> converting String to 
> Date");
>            }
>        }
> 
>        throw new ConversionException("Could not
> convert " +
>                                     
> value.getClass().getName() + " to " +
>                                     
> type.getName());
>    }
> }
> 
> To register:
> 
> ConvertUtils.register(new DateConverter(),
> Date.class);
> 
> >Am i saying something stupid???
> >
> >I'm not saying your code is wrong, but not
> appropriate
> >for the situation in question.
> >
> >Am i right?
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
>  


        
        
                
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! 
http://br.acesso.yahoo.com/

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

Reply via email to