What's the best way to parse an XML dateTime in Java?

后端 未结 9 1008
刺人心
刺人心 2020-11-28 06:16

What\'s the best way to parse an XML dateTime in Java? Legal dateTime values include 2002-10-10T12:00:00-05:00 AND 2002-10-10T17:00:00Z

Is there a good open source l

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 06:34

    In XML Beans v2 it would be XmlDateTime.Factory.parse(dateTimeString), but this is awkward because it expects an element with start and end tags like 2011-10-20T15:07:14.112-07:00

    An easier approach is to call (new org.apache.xmlbeans.GDate(dateTimeString)).getDate().

提交回复
热议问题