2012-09-14 63 views
0

Jettison庫返回的默認日期格式是否可以更改?更改Jettison中的日期默認格式

這是默認的日期格式

{ 「郵報」:{ 「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」 } }

可以說是改變了?

我們可以在Jakson中使用org.codehaus.jackson.map.JsonSerialize註釋來做到這一點。

如何在Jettison中執行此操作?

Jettison中是否有類似的類?

感謝

回答

0

這是可以用XMLAdapters

公共類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; 
} 

}

完成