【发布时间】:2011-08-12 03:54:54
【问题描述】:
我在将 Java 数据类型映射到标准架构日期数据类型时遇到了一些问题。
我有一个简单的类,我这样注释。 period 实例变量是 Java Date 对象类型。
@XmlAccessorType(value = XmlAccessType.NONE)
public class Chart {
@XmlElement
private double amount;
@XmlElement
private double amountDue;
@XmlElement
private Date period;
//constructor getters and setters
}
这是我的网络服务
@WebService
public class ChartFacade {
@WebMethod
public Chart getChart() throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd");
Chart chart = new Chart(20.0,20.5, df.parse("2001-01-01"));
return chart;
}
}
我的问题是它返回的日期数据格式不符合我的预期。
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getChartResponse xmlns:ns2="http://ss.ugbu.oracle.com/">
<return>
<amount>20.0</amount>
<amountDue>20.5</amountDue>
**<period>2001-01-01T00:01:00+08:00</period>**
</return>
</ns2:getChartResponse>
</S:Body>
</S:Envelope>
我希望像这样返回句点元素
<period>2001-01-01</period>
有什么方法可以实现吗?
【问题讨论】:
标签: java xml web-services xsd jaxb