users@jersey.java.net

[Jersey] Re: Provider for Joda's DateTime?

From: Jeremy Johnson <jeremy.johnson_at_imtc.gatech.edu>
Date: Mon, 26 Nov 2012 18:10:12 -0500

Thanks, Gili!

I modified your solution to use @Context injection for UriInfo rather than Guice and also made a change to avoid a null pointer exception upon a null DateTime query parameter. Works like a charm!

My code is here:
http://stackoverflow.com/questions/13482909/using-joda-datetime-as-a-jersey-parameter

Jeremy

From: cowwoc [mailto:cowwoc_at_bbs.darktech.org]
Sent: Thursday, November 22, 2012 11:57 AM
To: users_at_jersey.java.net
Subject: [Jersey] Re: Provider for Joda's DateTime?


    Fixed. Check again.

Gili

On 22/11/2012 3:16 AM, Marc CARRÉ wrote:
Hi Gili,

I replied to your post on StackOverflow, but I will post here too to centralize the information.
I would be interested in doing like Jeremy, and I use Jersey with Guice, but I face a few issues at the moment.
Could you please:

 * add the import statements used for your implementation?
 * add an example of how you bind everything with Guice?

Thank you very much in advance.

M.

2012/11/22 cowwoc <cowwoc_at_bbs.darktech.org<mailto:cowwoc_at_bbs.darktech.org>>

    I must have been out of my mind when I posted this. It's wrong :)

    I thought you were talking about request entities, not QueryParam. See http://stackoverflow.com/a/13500584/14731 for an updated answer.

Gili


On 21/11/2012 2:25 PM, cowwoc wrote:

    I posted a reply on Stackoverflow. In short: you don't need to inject DateTime. Just use it as a normal method parameter and it'll work.

Gili

On 21/11/2012 2:17 PM, Jeremy Johnson wrote:
Ah, thanks, Gili.

Looks like I left out the link to my question on Stack Overflow:
http://stackoverflow.com/questions/13482909/using-joda-datetime-as-a-jersey-parameter

The code in your link provides Jackson support for Joda, but doesn't provide for injection of Joda DataTime objects as Jersey query params, unless I'm missing something.

Thanks!
Jeremy

From: cowwoc [mailto:cowwoc_at_bbs.darktech.org]
Sent: Tuesday, November 20, 2012 6:34 PM
To: users_at_jersey.java.net<mailto:users_at_jersey.java.net>
Subject: [Jersey] Re: Provider for Joda's DateTime?

On 20/11/2012 5:43 PM, Jeremy Johnson wrote:
I'd like to accept Joda's DateTime objects as query parameters and understand that some flavor of injectable provider is needed.

Joda's DateTime is so ubiquitous, I was surprised to not find an implementation already out there beyond a couple of partial implementations on this list.

Does anyone have a working, reliable implementation they'd care to share? I also posted this to Stack Overflow, if you'd like to duplicate your response there as well for cred.

Thanks,
Jeremy

    It depends what resource representation format you're using. If you're using JSON with the Jackson library this will work: https://github.com/FasterXML/jackson-datatype-joda

PS: Where is the Stackoverflow question? :)

Gili