Code example for DatatypeFactory

Methods: newXMLGregorianCalendar

0
        try { 
            DatatypeFactory df = getDatatypeFactory();
            Date date = new Date(aNotification.getTimeStamp());
            GregorianCalendar gc = new GregorianCalendar();
            gc.setTime(date);
            jaxb.withDateTime(df.newXMLGregorianCalendar(gc));
 
            Object bean = wrap ? mObjectFactory.createNotificationEvent(jaxb) : jaxb;
 
            StringWriter sw = new StringWriter();
 
            // must create a new marshaller as its not thread safe 
            Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.marshal(bean, sw);
 
            return sw.toString();
        } catch (JAXBException e) {
            throw new NotificationFormatException(e);
        } catch (DatatypeConfigurationException e) {
            throw new NotificationFormatException(e);