在Jettison中更改日期默认格式

时间:2012-09-14 19:08:04

标签: jackson jettison

可以更改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中是否有类似的课程?

由于

1 个答案:

答案 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;
}

}

相关问题