Apache Axis-序列化为0001-01-01T00:00:00.000Z的日历实例 [英] Apache Axis - Calendar instance that gets serialized to 0001-01-01T00:00:00.000Z

查看:247
本文介绍了Apache Axis-序列化为0001-01-01T00:00:00.000Z的日历实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Axis与.Net编写的Web服务进行通信.

I'm using Apache Axis to communicate with a web service written in .Net.

当WS遇到DateTime.MinDate(即"0001-01-01")时,该WS中的功能之一会进行特殊处理.现在,我正在尝试将此特殊值发送到WS,但是在Java中似乎没有等效的DateTime.MinDate.

One of the functions in that WS has special handling when it encounters DateTime.MinDate (i.e. "0001-01-01"). Now, I'm trying to send this special value to the WS, but there seems to be no equivalent to DateTime.MinDate in Java.

您可能知道,Axis将xsd:dateTime包装到Calendar对象中,所以我尝试发送new GregorianCalendar(1 ,1 ,1);,但这并不能解决问题.我尝试了calendar.setTime(new Date(0)),我尝试了更多的组合,但是似乎没有任何序列化为

As you probably know, Axis wraps xsd:dateTime into Calendar objects, so I tried sending new GregorianCalendar(1 ,1 ,1); but this didn't do the trick. I tried calendar.setTime(new Date(0)), I tried many more combinations, but nothing seems to get serialized as

<endDate xsi:type="xsd:dateTime">0001-01-01T00:00:00.000Z</endDate>

这就是我所需要的.有谁知道如何实现这一目标?

which is what I need. Does anyone have any clue how can this be achieved?

推荐答案

以下内容将创建一个GregorianCalendar对象,该对象将序列化为等效对象 DateTime.MinValue.

The following will create a GregorianCalendar object that will serialize to the equivalent of DateTime.MinValue.

GregorianCalendar gc=new GregorianCalendar(1,0,1);
gc.setTimeZone(TimeZone.getTimeZone("GMT-0"));

请注意以下几点:

  • month参数从零开始,而不是1.
  • GregorianCalendar默认为本地时区,因此需要时区 手动调整.
  • The month parameter is zero based, not 1 based.
  • GregorianCalendar defaults to the local time zone, therefore the timezone needs to be adjusted manually.

这篇关于Apache Axis-序列化为0001-01-01T00:00:00.000Z的日历实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆