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

While running builds I noticed the following warning from Maven..

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

Rightfully so if you’re not using the correct convention for this..



type.setDate(new XMLGregorianCalendarImpl());


A quick look at Stackoverflow shows this: http://stackoverflow.com/a/5402007/1410035

In short you need to leverage a factory pattern and get an instance of the underlying implementation. The following snippet is an example of this:

import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
import java.util.GregorianCalendar;
//
//
private XMLGregorianCalendar now;
//
//

now = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());

And your code will be in better shape and future-proofed as well.

Leave a Reply

Your email address will not be published. Required fields are marked *