可以更改Jettison Library返回的默认日期格式吗?
这是默认的日期格式
{ “post”:{ “activityDate”:“ 2012-07-03T16:15:29.111-04:00 ”, “modfiedDate”:“ 2012-07-03T16:15:29.111-04:00 ”, “createdDate”:“ 2012-07-03T16:15:29.111-04:00 ” } }
可以改变吗?
我们可以使用org.codehaus.jackson.map.JsonSerialize注释在Jakson中执行此操作。
如何在Jettison中执行此操作?
Jettison中是否有类似的课程?
由于
答案 0 :(得分:0)
可以使用XMLAdapters
完成public class DateAdapter扩展了XmlAdapter {
/**
* This method is called when we return the DTO Date property to UI, We
* convert the date to UI date format
*/
@Override
public String marshal(Date inputDate) throws Exception {
.........
return dateStr;
}
/**
* This method is called when UI sends date String and we set the DTO Date
* property
*/
@Override
public Date unmarshal(String inputDateStr) throws Exception {
................
return inputdate;
}
}