code: @Override
    public DateMidnight deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException
    {
      // Do not try to deserialize null or empty values
      if (json.getAsString() == null || json.getAsString().isEmpty())
      {
        return null;
      }
  
      final DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
      return new DateMidnight(fmt.parseDateTime(json.getAsString()));
    }
docs: Gson invokes this call-back method during deserialization when it encounters a field of the
  specified type. <p>
  
  In the implementation of this call-back method, you should consider invoking
  {@link com.google.gson.JsonDeserializationContext#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type)} method to create objects
  for any non-trivial field of the returned object. However, you should never invoke it on the
  the same type passing {@code json} since that will cause an infinite loop (Gson will call your
  call-back method again).
  @param json The Json data being deserialized
  @param typeOfT The type of the Object to deserialize to
  @return a deserialized object of the specified type typeOfT which is a subclass of {@code T}
  @throws com.google.gson.JsonParseException if json is not in the expected format of {@code typeOfT}