/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package messageBodyWritersAndReaders; import java.io.IOException; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Calendar; import java.util.Date; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; /** * * @author Stefan */ @Provider public class DateMessageBodyWriter implements MessageBodyWriter{ @Override public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { return Date.class.isAssignableFrom(type); } @Override public long getSize(Date t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { return -1; } //izmeniti telo ove metode @Override public void writeTo(Date t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { } }