输入日期字符串: ( +0100"2016-02-06T00:00:00.000+0100"
中没有冒号)
有没有更好的方法来做到这一点。想知道是不是矫枉过正。
public static XMLGregorianCalendar convertStringToXMLGregorianCalendar(final String dateStrInXMLGregorianCalendar) {
try {
DateTime dateTime = ISODateTimeFormat.dateTime().parseDateTime(dateStrInXMLGregorianCalendar);
GregorianCalendar gregCal = new GregorianCalendar(dateTime.getZone().toTimeZone());
gregCal.setTimeInMillis(dateTime.getMillis());
return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregCal);
} catch (Exception e) {
throw new RuntimeException(String.format("Exception while converting %s to XMLGregorianCalendar!", dateStrInXMLGregorianCalendar), e);
}
}