首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

批改cxf rest的返回时间格式

2012-12-28 
修改cxf rest的返回时间格式参考:http://stackoverflow.com/questions/2519432/jaxb-unmarshal-timestamp?

修改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格式。

?

?

热点排行