You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide ParamConverterProvider implementations for all date/time types that make sense to use as query parameters. For example, here is an implementation I used to pass LocalDateTime as a query parameter (feel free to use it):
/**
* Enables LocalDateTime to be used as a QueryParam.
*
* @author Gili Tzabari
*/
@Provider
@Singleton
public class LocalDateTimeConverter implements ParamConverterProvider {
@Override public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
if (!rawType.isAssignableFrom(LocalDateTime.class)) {
return null;
}
return new ParamConverter<T>() {
@Override
@SuppressWarnings("unchecked")
public T fromString(final String value) {
if (value == null) {
throw new IllegalArgumentException("value may not be null");
}
return (T) LocalDateTime.parse(value);
}
@Override
public String toString(final T value) {
return ((LocalDateTime) value).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
};
}
}
The text was updated successfully, but these errors were encountered:
Also just realized that there are some subtleties wrt where to locate this (project-wise), due to dependency to Java 8.
But one thing I am wondering is this: since nothing in above relies on Jackson, does this even make sense here? Ideally various configuration settings would be used, but unless there is some way to access ObjectMapper or ObjectReader, that can't be done. So in a way maybe this would belong more to DropWizard project?
(Copied from FasterXML/jackson-modules-java8#7)
Please provide
ParamConverterProvider
implementations for all date/time types that make sense to use as query parameters. For example, here is an implementation I used to passLocalDateTime
as a query parameter (feel free to use it):The text was updated successfully, but these errors were encountered: