Exception in thread "main" java.lang.IllegalStateException: com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl#getXMLSchemaType() :Invalid set of fields set for XMLGregorianCalendar at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.getXMLSchemaType(XMLGregorianCalendarImpl.java:1928) at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.toXMLFormat(XMLGregorianCalendarImpl.java:1764) at javax.xml.datatype.XMLGregorianCalendar.toString(XMLGregorianCalendar.java:866)
I was getting the above exception when I try to run the following code...
XMLGregorianCalendar tmStamp = new XMLGregorianCalendarImpl(); tmStamp.setYear(2011); tmStamp.setMonth(Calendar.NOVEMBER); tmStamp.setDay(30); tmStamp.setHour(10); tmStamp.setMinute(59); System.out.println(tmStamp.toString());
Solution:
Set the seconds as well
tmStamp.setSeconds(30);
Setting the seconds is mandatory when you set hours and minutes.
No comments:
Post a Comment