I forgot about the locale. The following does works:

public class JodaTimeConverter implements TypeConverter<DateTime>
{
    DateTypeConverter dateTypeConverter = new DateTypeConverter();

    public DateTime convert(String fromVal, Class<? extends DateTime>
targetClass, Collection<ValidationError> errors)
    {
        Date date = dateTypeConverter.convert(fromVal, Date.class, errors);
        DateTime jodaTime = new DateTime(date);
        return jodaTime;
    }

    public void setLocale(Locale locale) {
        dateTypeConverter.setLocale(locale);
    }

}


Cheers,
Yee

Stripes rocks!!


On Mon, Dec 15, 2008 at 11:37 AM, CN Yee <[email protected]> wrote:

> I cannot extend the existing converter because I need the jodaTime
> signature in the generic class definition, i.e.
>
> public class JodaTimeConverter implements
> TypeConverter<org.joda.time.DateTime>
>
> otherwise Stripes throws a runtimeexception.
>
> I tried the following but got a null pointer exception on
> dateTypeConverter.convert()
>
>     public DateTime convert(String fromVal, Class<? extends DateTime>
> targetClass, Collection<ValidationError> errors)
>     {
>         DateTypeConverter dateTypeConverter = new DateTypeConverter();
>         Date date = dateTypeConverter.convert(fromVal, Date.class, errors);
>
>         DateTime jodaTime = new DateTime(date);
>         return jodaTime;
>     }
>
> Do you have other pointers?
>
> Thanks
> Yee
>
>
> From: Gregg Bolinger 
> <gdboling.stri...@...<http://gmane.org/get-address.php?address=gdboling.stripes%2dRe5JQEeQqe8AvxtiuMwx3w%40public.gmane.org>
> >
> Subject: Re: Calling Stripes converter from within a custom 
> converter?<http://news.gmane.org/find-root.php?message_id=%3ca24e82a90812141846i41ea3bd4yc1444813afc93e61%40mail.gmail.com%3e>
> Newsgroups: 
> gmane.comp.java.stripes.user<http://news.gmane.org/gmane.comp.java.stripes.user>
> Date: 2008-12-15 02:46:37 GMT (40 minutes ago)
>
>  I've not tried this but can you extends the existing converter and in the
> convert method just call super.convert ??
>
> Gregg
>>
>>
>> Yee
>>
>
>
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to