Code example for JsonPrimitive

0
 
public class DateTimeTypeConverter  implements JsonSerializer<DateTime>, JsonDeserializer<DateTime>  {
      // No need for an InstanceCreator since DateTime provides a no-args constructor 
      @Override 
      public JsonElement serialize(DateTime src, Type srcType, JsonSerializationContext context) {
        return new JsonPrimitive(src.toString());
      } 
      @Override 
      public DateTime deserialize(JsonElement json, Type type, JsonDeserializationContext context)
          throws JsonParseException { 
        return new DateTime(json.getAsString());
      } 
}