解決Gson解析Date資料格式的問題

dingcheng998發表於2016-11-16
 GsonBuilder builder = new GsonBuilder();
 builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
     public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
         return new Date(json.getAsJsonPrimitive().getAsLong());
     }
 });
Gson gson = builder.create();

相關文章