Skip to content

Instantly share code, notes, and snippets.

@wulfgarpro
Created September 13, 2011 04:29
Show Gist options
  • Save wulfgarpro/1213119 to your computer and use it in GitHub Desktop.
Save wulfgarpro/1213119 to your computer and use it in GitHub Desktop.
Custom gson serializer
Gson gson = new GsonBuilder().registerTypeAdapter(ObjectId.class,
new JsonSerializer<ObjectId>()
{
public JsonElement serialize(ObjectId t, Type type,
JsonSerializationContext jsc)
{
return new JsonPrimitive(t.toString());
}
}).setDateFormat("MMMM dd, yyyy HH:mm:ss").create();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment