package me.pagar.util;

import com.google.common.base.Strings;
import com.google.gson.*;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

import java.lang.reflect.Type;

public class LocalDateAdapter implements JsonDeserializer<LocalDate>, JsonSerializer<LocalDate> {

    private final DateTimeFormatter formatter;

    public LocalDateAdapter() {
        this.formatter = ISODateTimeFormat
                .localDateParser();
    }

    @Override
    public LocalDate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        final String dateTime = json.getAsString();
        return Strings.isNullOrEmpty(dateTime) ? null : formatter.parseLocalDate(dateTime);
    }

    @Override
    public JsonElement serialize(LocalDate src, Type typeOfSrc, JsonSerializationContext context) {
        return src == null ? null : new JsonPrimitive(formatter.print(src));
    }

}

@@ -161,16 +161,60 @@
 matter;%0A
+import org.joda.time.format.DateTimeFormat;%0A
 import o
@@ -489,19 +489,16 @@
 atter = 
-ISO
 DateTime
@@ -507,42 +507,44 @@
 rmat
-%0A                .localDateParser(
+.forPattern(%22yyyy-MM-dd'T'HH:mm:ssZ%22
 );%0A 

add another date format for local date