All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JavaJaxRS.resteasy.OffsetDateTimeProvider.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
package {{apiPackage}};

import java.time.OffsetDateTime;
import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.ParamConverterProvider;
import javax.ws.rs.ext.Provider;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

@Provider
public class OffsetDateTimeProvider implements ParamConverterProvider {

    public static class OffsetDateTimeConverter implements ParamConverter {

        public OffsetDateTime fromString(String string) {
            OffsetDateTime offsetDateTime = OffsetDateTime.parse(string);
            return offsetDateTime;
        }

        public String toString(OffsetDateTime t) {
            return t.toString();
        }
    }

    public  ParamConverter getConverter(Class type, Type type1, Annotation[] antns) {
        if (OffsetDateTime.class.equals(type)) {
            return (ParamConverter) new OffsetDateTimeConverter();
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy