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