Search in sources :

Example 46 with DatatypeConfigurationException

use of javax.xml.datatype.DatatypeConfigurationException in project rdf4j by eclipse.

the class ValueFactoryTest method testCreateLiteralXMLGregorianCalendar.

/**
 * Test method for
 * {@link org.eclipse.rdf4j.model.impl.AbstractValueFactory#createLiteral(javax.xml.datatype.XMLGregorianCalendar)}
 * .
 */
@Test
public void testCreateLiteralXMLGregorianCalendar() {
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(new Date());
    try {
        XMLGregorianCalendar xmlGregCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
        Literal l = f.createLiteral(xmlGregCalendar);
        assertNotNull(l);
        assertEquals(l.getDatatype(), XMLSchema.DATETIME);
    // TODO check lexical value?
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
        fail("Could not instantiate javax.xml.datatype.DatatypeFactory");
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date) Test(org.junit.Test)

Example 47 with DatatypeConfigurationException

use of javax.xml.datatype.DatatypeConfigurationException in project open-ecard by ecsec.

the class MwEventManager method initialize.

public void initialize() throws InitializationException {
    // start watcher thread
    try {
        DatatypeFactory dataFactory = DatatypeFactory.newInstance();
        MwEventRunner runner = new MwEventRunner(env, builder, dataFactory, mwSAL.getMwModule(), mwCallback);
        runner.initRunner();
        watcher = new FutureTask<>(runner, null);
        Thread t = new Thread(watcher, "MwEventManager");
        t.start();
    } catch (CryptokiException ex) {
        LOG.error("Failed to initialize middleware event runner.", ex);
        throw new InitializationException("Failed to request initial status from middleware.", ex.getErrorCode());
    } catch (DatatypeConfigurationException ex) {
        throw new UnsupportedOperationException("Datatype factory not supported.", ex);
    }
}
Also used : DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException)

Example 48 with DatatypeConfigurationException

use of javax.xml.datatype.DatatypeConfigurationException in project AJSC by att.

the class Time method toXMLCalendar.

/**
 * Converts java Date to XMLGregorianCalendar.
 *
 * @param date
 *            The date to convert
 * @return The XMLGregorianCalendar for the specified date
 */
@SuppressWarnings("nls")
public static XMLGregorianCalendar toXMLCalendar(final Date date) {
    GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
    cal.setTime(date);
    XMLGregorianCalendar xmlCal = null;
    try {
        xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    } catch (DatatypeConfigurationException e) {
        LOG.error("toXMLCalendar", e);
    }
    return xmlCal;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 49 with DatatypeConfigurationException

use of javax.xml.datatype.DatatypeConfigurationException in project onebusaway-application-modules by camsys.

the class DateUtil method toXmlGregorianCalendar.

public static XMLGregorianCalendar toXmlGregorianCalendar(long timestamp) {
    // to Gregorian Calendar
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTimeInMillis(timestamp);
    // to XML Gregorian Calendar
    try {
        return DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
    } catch (DatatypeConfigurationException e) {
        _log.error("Error converting timestamp to XMLGregorianCalendar", e);
        return null;
    }
}
Also used : DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 50 with DatatypeConfigurationException

use of javax.xml.datatype.DatatypeConfigurationException in project jbossws-cxf by jbossws.

the class RegistrationServiceImpl method getCalendar.

private XMLGregorianCalendar getCalendar() {
    try {
        DatatypeFactory calFactory = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = calFactory.newXMLGregorianCalendar(2002, 4, 5, 0, 0, 0, 0, 0);
        return cal;
    } catch (DatatypeConfigurationException e) {
        throw new RuntimeException(e);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory)

Aggregations

DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)56 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)35 GregorianCalendar (java.util.GregorianCalendar)33 DatatypeFactory (javax.xml.datatype.DatatypeFactory)20 Date (java.util.Date)18 BigInteger (java.math.BigInteger)6 ParseException (java.text.ParseException)6 JAXBException (javax.xml.bind.JAXBException)5 QName (javax.xml.namespace.QName)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ConverterException (ch.ehi.ili2db.converter.ConverterException)2 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)2 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)2 NumericType (ch.interlis.ili2c.metamodel.NumericType)2 PrecisionDecimal (ch.interlis.ili2c.metamodel.PrecisionDecimal)2 IomObject (ch.interlis.iom.IomObject)2 ArrayOfString (com.marketo.mktows.ArrayOfString)2 LastUpdateAtSelector (com.marketo.mktows.LastUpdateAtSelector)2 File (java.io.File)2