Tagged: milliseconds

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.