我收到以下ParseException: 无法解释的日期:" Mai 18,1987"
我正在尝试解析并将其作为日期返回...
代码是:
public class JsonDateDeserializer implements JsonDeserializer<Date> {
@Override
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
try {
String s = json.getAsJsonPrimitive().getAsString();
DateFormat format = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
Date date = format.parse(s);
return date;
} catch (ParseException ex) {
Logger.getLogger(JsonDateDeserializer.class.getName()).log(Level.SEVERE, null, ex);
Date date = null;
return date;
}
}
}
Thx 4提前帮助