How do I represent dates without the timezone using Apache CXF?

后端 未结 4 2007
暗喜
暗喜 2021-02-04 05:52

I have a WSDL that specifies an element\'s type to be xs:date.

When I use Apache CXF to generate the Java classes, it renders the variable as an javax.xml.datatype.XMLGr

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 06:06

    GregorianCalendar gcal = new GregorianCalendar();
    start = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
    start.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
    

    Don't ask me why in every bit of the sane logic - when marshalling the XMLgregorianCalendar to xs:date it retains the time zone.

    I always thought - the time zone could be more applicable to xs:dateTime, but what I know ... about types.

    For me, it doesn't make sense to have the time zone by default, for a xs:date type and this is a problem in the marshalling logic.

提交回复
热议问题