gson格式转换
public ApiClient(){
this.setGson(new GsonBuilder()
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeDeserializer())
.create());
}
public class OffsetDateTimeDeserializer implements JsonDeserializer<OffsetDateTime> {
@Override
public OffsetDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String dateString = json.getAsJsonPrimitive().getAsString();
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
return OffsetDateTime.parse(dateString, formatter);
} catch (DateTimeParseException e) {
throw new JsonParseException("Unable to parse date string: " + dateString, e);
}
}
}