Jeff Sexton

Thursday, April 14, 2011

Create an XMLGregorianCalendar for the Current Date/Time

Creating a XML calendar object suitable for use in SOAP messages, in Java, is simple enough.

    public XMLGregorianCalendar getXMLGregorianCalendarNow() 
            throws DatatypeConfigurationException
    {
        GregorianCalendar gregorianCalendar = new GregorianCalendar();
        DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
        XMLGregorianCalendar now = 
            datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
        return now;
    }


Enhanced by Zemanta

0 comments:

Wanted

Good price paid for accumulations and estates of vintage mechanical watch and pocketwatch material and parts. Pre-quartz, pre-battery, Elgin and other American brands in particular, Swiss material less so. Note that I am a watchmaker working to keep the craft alive and well, I am not an antique dealer looking to buy and resell.
Contact jsexton@agora.rdrop.com  - Thanks!