package tracker_java.Utilities;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;


/**
 * Created by cristian on 10/26/15.
 */
@Provider
public class MyObjectMapperProvider implements ContextResolver<ObjectMapper> {

    final ObjectMapper defaultObjectMapper;

    public MyObjectMapperProvider() {
        defaultObjectMapper = createDefaultMapper();
    }

    @Override
    public ObjectMapper getContext(final Class<?> type) {

        return defaultObjectMapper;
    }

    private static ObjectMapper createDefaultMapper() {
        final ObjectMapper result = new ObjectMapper();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        result.enable(SerializationFeature.INDENT_OUTPUT);
        result.setDateFormat(dateFormat);
        return result;
    }

    private static AnnotationIntrospector createJaxbJacksonAnnotationIntrospector() {

        final AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
        final AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();

        return AnnotationIntrospector.pair(jacksonIntrospector, jaxbIntrospector);
    }
}
@@ -274,16 +274,75 @@
 eature;%0A
+import com.fasterxml.jackson.databind.SerializationConfig;%0A
 import c
@@ -1141,153 +1141,8 @@
 ();%0A
-        DateFormat dateFormat = new SimpleDateFormat(%22yyyy-MM-dd'T'HH:mm:ss.SSSZ%22);%0A        dateFormat.setTimeZone(TimeZone.getTimeZone(%22GMT%22));%0A
     
@@ -1196,20 +1196,17 @@
 UTPUT);%0A
-    
+%09
     resu
@@ -1212,32 +1212,71 @@
 ult.
-setDateFormat(dateFormat
+configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false
 );%0A 
@@ -1697,8 +1697,9 @@
 %0A    %7D%0A%7D
+%0A

use ISO format;