I wrote some code that required an XMLGregorianCalendar so when I poked around with code completion, the first thing I found was a constructor on This got my code working but when you build with Maven, you get given a warning (and rightly so):

XMLGregorianCalendarImpl is internal proprietary API and may be removed in a future release

The fix:

The correct way to get something that conforms to the XMLGregorianCalendar interface is to call this factory:

XMLGregorianCalendar cal = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar();

Credit to the SO answer at for how to do it.