I think you can user XmlAdapters [1][2] for that
[1]
https://www.eclipse.org/eclipselink/documentation/2.4/moxy/advanced_concepts006.htm
[2]
http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html
Cheers,
Pedro
From: Louis Crandell [mailto:crandell.louis_at_gmail.com]
Sent: 20 February 2014 02:46
To: users_at_jersey.java.net
Subject: [Jersey] Re: Joda DateTime
What if the DateTime is part of an object payload rather than a query? I'm seeing a complex object with miliseconds inside and using the integrated MOXy JSON marshaller, eg. "endDate":{"chronology":{},"millis":1393246833962}
On Wed, Feb 12, 2014 at 2:56 PM, Miles, Eric (CONT) <Eric.Miles_at_capitalone.com<mailto:Eric.Miles_at_capitalone.com>> wrote:
Don't know, I'm guessing the Jersey guys could comment on that. Multiple
ways to skin a cat, choose what works best for you and your project.
Eric Miles
On 2/12/14 5:13 AM, "Oliver B. Fischer" <mailsink_at_swe-blog.net<mailto:mailsink_at_swe-blog.net>> wrote:
>What is the advantage of a ParamConverter over a custom parameter class?
>
>Am 04.02.14 18:55, schrieb Miles, Eric (CONT):
>> This is super easy, implement a javax.ws.rs.ext.ParamConverterProvider
>> and javax.ws.rs.ext.ParamConverter<T>. Here are some snippets for
>> Instants from Joda:
>>
>> @Override
>>
>> public T fromString(String value) {
>>
>> return
>>
>>rawType.cast(ISODateTimeFormat.dateTimeParser().parseDateTime(value).toIn
>>stant());
>>
>> }
>>
>>
>> @Override
>>
>> public String toString(T value) {
>>
>> return ISODateTimeFormat.dateTime().print((Instant) value);
>>
>> }
>>
>>
>> public static class Binder extends AbstractBinder {
>>
>> @Override
>>
>> protected void configure() {
>>
>>
>>
>>bind(InstantParamConverterProvider.class).to(ParamConverterProvider.class
>>).in(Singleton.class)
>>
>> .qualifiedBy(new CustomAnnotationImpl());
>>
>> }
>>
>> }
>>
>>
>> There are tons of ParamConverterProviders included in Jersey2, take a
>> look at those to close the gap with what I provided.
>>
>>
>> From: Robert DiFalco <robert.difalco_at_gmail.com<mailto:robert.difalco_at_gmail.com>
>> <mailto:robert.difalco_at_gmail.com<mailto:robert.difalco_at_gmail.com>>>
>> Reply-To: Jersey Users <users_at_jersey.java.net<mailto:users_at_jersey.java.net>
>> <mailto:users_at_jersey.java.net<mailto:users_at_jersey.java.net>>>
>> Date: Tuesday, February 4, 2014 12:02 PM
>> To: Jersey Users <users_at_jersey.java.net<mailto:users_at_jersey.java.net> <mailto:users_at_jersey.java.net<mailto:users_at_jersey.java.net>>>
>> Subject: [Jersey] Re: Joda DateTime
>>
>> It's not an issue of jackson and joda. That's easy it's an issue of a
>> Joda Time Query parameter in Jersey. It's a different issue/solution.
>> For now I'm making the query parameter a string and parsing it
>> immediately with Joda.
>>
>>
>> On Tue, Feb 4, 2014 at 8:54 AM, Michael Iles <michael.iles_at_gmail.com<mailto:michael.iles_at_gmail.com>
>> <mailto:michael.iles_at_gmail.com<mailto:michael.iles_at_gmail.com>>> wrote:
>>
>> I second the vote for ISO 8601.
>>
>> Jackson and Joda Time are straightforward to use in Jersey 2.0:
>>
>> <!-- Jackson provider for Jersey -->
>>
>> <dependency>
>> <groupId>com.fasterxml.jackson.jaxrs</groupId>
>> <artifactId>jackson-jaxrs-json-provider</artifactId>
>> <version>2.2.3</version>
>> </dependency>
>>
>> <!-- Jackson provider for Joda Time -->
>>
>> <dependency>
>> <groupId>com.fasterxml.jackson.datatype</groupId>
>> <artifactId>jackson-datatype-joda</artifactId>
>> <version>2.1.1</version>
>> </dependency>
>>
>> However, Jersey 2.0 makes it hard to configure Jackson, e.g. if you
>> want to disable SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
>>(which
>> I would recommend). See other postings in this forum for details.
>>
>> Mike.
>>
>> On 4 February 2014 11:01, cowwoc <cowwoc_at_bbs.darktech.org<mailto:cowwoc_at_bbs.darktech.org>
>> <mailto:cowwoc_at_bbs.darktech.org<mailto:cowwoc_at_bbs.darktech.org>>> wrote:
>> > I'd recommend ISO8601
>>instead:http://en.wikipedia.org/wiki/ISO_8601
>> >
>> > In Jersey 1.0, it was pretty easy to configure Jackson to
>>serialize this
>> > back and forth. No idea about Jersey 2.0 though.
>> >
>> > Gili
>> >
>> >
>> > On 04/02/2014 10:43 AM, Paulo Pires wrote:
>> >
>> > Hi Robert,
>> >
>> > Why don't you use timestamp in milliseconds (UTC) and transform
>>with Joda
>> > Time?
>> >
>> > PP
>> >
>> >
>> > On Mon, Feb 3, 2014 at 9:30 AM, Jakub Podlesak
>><jakub.podlesak_at_oracle.com<mailto:jakub.podlesak_at_oracle.com> <mailto:jakub.podlesak_at_oracle.com<mailto:jakub.podlesak_at_oracle.com>>>
>> > wrote:
>> >>
>> >> Hi Robert,
>> >>
>> >> There is no such Jersey feature to enable Joda DateTime as a
>>query param
>> >> available.
>> >> You can however write your own JAX-RS ParamConverter provider
>>and
>> >> register it via
>> >> ParamConverterProvider as documented here:
>> >>
>> >>
>>
>>>>https://jersey.java.net/apidocs/latest/jersey/javax/ws/rs/ext/ParamConv
>>>>erter.html
>> >>
>> >> HTH,
>> >>
>> >> ~Jakub
>> >>
>> >> On 02 Feb 2014, at 00:57, Robert DiFalco
>><robert.difalco_at_gmail.com<mailto:robert.difalco_at_gmail.com> <mailto:robert.difalco_at_gmail.com<mailto:robert.difalco_at_gmail.com>>> wrote:
>> >>
>> >> I'm probably being dense here but how do I use Joda DateTime as a
>> >> QueryParam? I have the JodaModule setup with Jackson, but I
>>guess I need
>> >> more than that. I googled around and found solutions that
>>required all kinds
>> >> of code. Isn't there a JerseyFeature or some such that will
>>allow me to use
>> >> Joda DateTime as a QueryParam?
>> >>
>> >> The error I get is this:
>> >>
>> >> org.glassfish.jersey.server.model.ModelValidationException:
>>Validation of
>> >> the application resource model has failed during application
>> >> initialization.|[[FATAL] No injection source found for a
>>parameter of type
>> >> public java.lang.String
>> >>
>>com.myapp.rest.service.DevicesResource.getExpiredDevices(org.joda.time.Da
>>teTime)
>> >> throws java.lang.Exception
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Paulo Pires
>> >
>> >
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> The information contained in this e-mail is confidential and/or
>> proprietary to Capital One and/or its affiliates. The information
>> transmitted herewith is intended only for use by the individual or
>> entity to which it is addressed. If the reader of this message is not
>> the intended recipient, you are hereby notified that any review,
>> retransmission, dissemination, distribution, copying or other use of, or
>> taking of any action in reliance upon this information is strictly
>> prohibited. If you have received this communication in error, please
>> contact the sender and delete the material from your computer.
>>
________________________________________________________
The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.