Gson报错Invalid time zone indicator 的处理
This commit is contained in:
parent
eb72e3fb74
commit
e5cea2d03b
|
@ -1,8 +1,7 @@
|
|||
package io.renren.modules.demanData.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.*;
|
||||
import io.renren.modules.demanData.dto.TDemandDataDTO;
|
||||
import io.renren.modules.demanData.service.TDemandDataService;
|
||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||
|
@ -22,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -51,7 +52,7 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
|
|||
|
||||
@Override
|
||||
public void notify(DelegateExecution execution) throws Exception {
|
||||
|
||||
execution.getProcessBusinessKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +101,15 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
|
|||
|
||||
private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) {
|
||||
Map<String, Object> kv = delegateTask.getVariables();
|
||||
Gson gson = new Gson();
|
||||
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();
|
||||
// Gson gson = new Gson();
|
||||
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||
TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class);
|
||||
|
||||
|
|
Loading…
Reference in New Issue