2
我试图反序列化的时间字符串到乔达日期时间一般价值,所以我定义这个解串器:通用类,不能返回
public class JsonTimeDeserializer<T extends DateTime> implements JsonDeserializer<T> {
@Override
public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
DateTimeFormatter dtf = DateTimeFormat.forPattern("HH:mm");
return json == null ? null : dtf.parseDateTime(json.getAsString());
}
}
我越来越:
required: T
Found org.joda.time.DateTime
我不明白。 T扩展DateTime。
我在做什么错?
感谢
是什么让你认为'T == DateTime'给出了一个字面上方的行,声明'T扩展DateTime'。事实上,为什么这是通用的? –
好的。我明白你的意思 –