I have a JsonElement {"iMillis":1465936837501,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}}. I want to deserialize it to joda DateTime.
I am trying to use custom deserializer:
class DateTimeDeserializer implements JsonDeserializer<DateTime> {
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return new DateTime(json.getAsJsonPrimitive().getAsString());
}
}
But this gives me error that given json is not a json primitive. I have also tried direct json.getAsString() but that gives an UnsupportedOperationException error.
Can anyone help me with this de-serialization?
Thanks!