读书人

批改cxf rest的返回时间格式

发布时间: 2012-12-28 10:29:05 作者: rapoo

修改cxf rest的返回时间格式

参考:http://stackoverflow.com/questions/2519432/jaxb-unmarshal-timestamp

?

?

cxf rest默认使用2010-08-23T20:32:43.609+08:00这种时间格式,我们可以通过定义annotation来改变它。
新建annotation:

?

@XmlRootElement(name = "resp")@XmlAccessorType( XmlAccessType.FIELD )public class BaseRespObj {@XmlJavaTypeAdapter(DateAdapter.class)private Date date;@XmlElement(name = "infocode")private ResultCode code;

?

?

将注解@XmlJavaTypeAdapter(DateAdapter.class)放在时间属性上即可。此时时间将返回2010-08-23 20:32:43格式。

?

?

读书人网 >编程

热点推荐