即使记录在Android中,是不是可以使用XMLGregorianCalendar? [英] Can't use XMLGregorianCalendar in Android, even if it is documented?
问题描述
我真的不明白这一点:看起来Android有XMLGregorianCalendar类,因为它被记录在一起这里。
但是如果你继续尝试使用它,那就是你所得到的:
10-27 17:21 :43.677:E / AndroidRuntime(14850):导致:javax.xml.datatype.DatatypeConfigurationException:Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl未找到
10-27 17:21:43.677:E / AndroidRuntime(14850):在javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:102)
发生这种情况:
DatatypeFactory datatype = DatatypeFactory.newInstance();
并且猜测它不应该像这样,正如官方 Android Javadoc 。
这似乎是关于Android的不太聪明的事情之一。你为什么要记录一些不能使用的东西?
有没有人有解决方案,可能不包括重新包装?
自v8以来,API已经在API中,没有任何版本的Android随附实施。一个方法是下载 Xerces2 Java实现 jar并将其包含在项目的构建路径上。
您的代码将略有不同:
DatatypeFactory datatype = DatatypeFactoryImpl.newInstance();
I really can't understand this one: it looks like Android has the XMLGregorianCalendar class, because it is documented here. But if you go ahead and try to use it, that's what you get:
10-27 17:21:43.677: E/AndroidRuntime(14850): Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found
10-27 17:21:43.677: E/AndroidRuntime(14850): at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:102)
This happens on the line:
DatatypeFactory datatype = DatatypeFactory.newInstance();
And guess what, it should not behave like this, as documented on the official Android Javadoc.
This looks like one of the not-so-smart things about Android. Why would you document something that can't be used? Does anyone have a solution on this, one that maybe does not include repackaging?
It looks like even though it's been in the API since v8, no version of Android has ever shipped with an implementation. Handy, right?
One solution is to download the Xerces2 Java implementation jar and include it on your project's build path.
Your code would be only slightly different:
DatatypeFactory datatype = DatatypeFactoryImpl.newInstance();
这篇关于即使记录在Android中,是不是可以使用XMLGregorianCalendar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!