Created
September 13, 2011 04:29
-
-
Save wulfgarpro/1213119 to your computer and use it in GitHub Desktop.
Custom gson serializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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