我正在尝试从数据类型为 java.util.calendar
的 Web 服务检索时间值 (05:58:41.000),并将其重新发送回服务。
在重新发送回来时,我想知道是否附加了额外的 Z(时区文本),如下所示。
(05:58:41.000Z)
这是日历的预期行为吗?有什么办法可以修剪时区文本(Z)吗?
非常感谢您对此的帮助。
我的代码并不复杂,非常简单。
我的 POJO 类是:
Class A {
private java.util.Calendar time;
public void setTime(Calendar theTime) {
time = theTime;
}
public Calendar getTime() {
return time;
}
}
映射代码如下所示
class Mapping {
//Invoke a service A and assign the mapping
A.setTime(serviceResponse.getTime());
// from service getting value as 05:58:41.000
//Invoke the service B by resending the time value as such
request.setTime(A.getTime());
// While resending back value in the request shows as 05:58:41.000Z
}
最佳答案
在您的 request.setTime(A.getTime());
中采用局部变量对数据进行所需的更改并将其设置为 request.setTime(localVariable);
关于java - java中的日历问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18741114/