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");
}
}
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);
}
}
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;
}
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;
}
}
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);
}
}
Aggregations