users@jersey.java.net

[Jersey] Re: Date parameter in the url

From: Sean Landis <sean.landis_at_gmail.com>
Date: Mon, 20 Jun 2011 12:23:04 -0600

Hi Paul,

You could try creating your own wrapper class around SimpleDateFormat.
The wrapper would have the signatures acceptable to @PathParam and
would delegate the parsing to SimpleDateFormat. I haven't tried it but
that's where I'd start.
Sean

On Mon, Jun 20, 2011 at 6:49 AM, Paul <nibin.cse_at_gmail.com> wrote:
> For PathParam, the following are the valid paratemer types.
>
> 1. Primitive types.
> 2. Types that have a constructor that accepts a single String argument.
> 3. Types that have a static method named valueOf or fromString with a single
> String argument
> that return an instance of the type. If both methods are present then
> valueOf MUST be used unless
> the type is an enum in which case fromStringMUST be used.
> 4. List<T>, Set<T>, or SortedSet<T>, where T satisfies 2 or 3 above.
>
> Since java.util.Date has a constructor that accepts string, I think
> java.util.Date could be used as the parameter type.
>
> But public Date(String s) constructor is deprecated.
>
> And I don't think the date in the format (2011%06%17) is valid. The parsing
> of the date string might fail. But if you provide the date in an acceptable
> format, then I guess, it should work fine.
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Date-parameter-in-the-url-tp6485543p6495635.html
> Sent from the Jersey mailing list archive at Nabble.com.
>