mapping a milliseconds parameter directly into a date instance in jax-rs


@POST
public void myResource(
    @QueryParam("milliseconds")
    @NotNull
    final Long milliseconds) {

    final Date date = new Date(milliseconds);
    myService(date);
}

I wrote some codes using ParamConverter and ParamConverterProvider.
And now I can do like this.

@POST
public void myResource(
    @QueryParam("milliseconds")
    @NotNull
    @MillisecondsParam
    final Date date) {

    myService(date);
}

Here are 3 classes for this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s