English 中文(简体)
页: 1 日历原因
原标题:xsd:datetime and XmlGregorianCalendar causes NullPointerException

以下著作:

public Date getDate() {
    return date;
}

并产生类似的东西:

<date>2010-03-23T17:43:50.879Z</date>

我可以使用XmlGregorianCalendar来回xsd:date或xsd: 时间类型罚款:

@XmlSchemaType(name="date")
public XmlGregorianCalendar getDate() {
    return date;
}

产生类似的东西:

<date>2010-03-23</date>

但是,试图返回xsd:时间不变:

@XmlSchemaType(name="datetime")
public XmlGregorianCalendar getDate() {
     return date;
}

造成这种 st痕:

java.lang.NullPointerException
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.checkXmlGregorianCalendarFieldRef(RuntimeBuiltinLeafInfoImpl.java:864)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.access$200(RuntimeBuiltinLeafInfoImpl.java:111)
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.print(RuntimeBuiltinLeafInfoImpl.java:536)
...snip...
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)

这根本不提我的法典。

Im using tomcat 6.0.24, java 1.6.0_16-b01

最佳回答

我发现基本问题: 应为<代码>“日期”而不是>datetime>,然而,这方面的内容更为深入。

首先,这些痕迹给我提供的帮助很少,而我却在寻找合适的来源(jaxb-ri-2_2.src.zip)。 第864条是:

int bitField = xmlGregorianCalendarFieldRef.get(type);

http://www.un.org。

private static final Map<QName, Integer> xmlGregorianCalendarFieldRef =
            new HashMap<QName, Integer>();
    static {
            Map<QName, Integer> f = xmlGregorianCalendarFieldRef;
            f.put(DatatypeConstants.DATETIME,   0x1111111);
            f.put(DatatypeConstants.DATE,       0x1111000);
            f.put(DatatypeConstants.TIME,       0x1000111);
            f.put(DatatypeConstants.GDAY,       0x1001000);
            f.put(DatatypeConstants.GMONTH,     0x1010000);
            f.put(DatatypeConstants.GYEAR,      0x1100000);
            f.put(DatatypeConstants.GYEARMONTH, 0x1110000);
            f.put(DatatypeConstants.GMONTHDAY,  0x1011000);
    }

因此,xmlGregorianCalendar FieldRef 本身可能是无效的,但如果在get(>上标有地图上的钥匙,则该代码将予退回,而NullPointerException则在联合考试委员会试图将其箱中抛出时将投下。

这部法典是一种微薄的缩略语;其类型价值被检查,因此我们获得了这种相当的加密信息。

显然,我研究了<代码>的价值。 数据型Constants.DATETIME发现案件错误。

这还导致我相信,我或许会利用这样的东西:

@XmlSchemaType(name=DatatypeConstants.DATETIME)
public XmlGregorianCalendar getDate() {
    return date;
}

添加保护,but <>>>>>,不变为QName,不作指示。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...