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);
}
}
use of javax.xml.datatype.DatatypeConfigurationException in project OpenMEAP by OpenMEAP.
the class TransactionDateComparatorTest method testDateComparator.
@Test
public void testDateComparator() {
DatatypeFactory df = null;
try {
df = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException dce) {
throw new RuntimeException(dce);
}
List<Transaction> tl = new ArrayList<Transaction>();
Transaction t = new Transaction();
t.setAcctNumber("1");
t.setDate(df.newXMLGregorianCalendar("2011-03-03T12:00:00+03:00"));
tl.add(t);
t = new Transaction();
t.setAcctNumber("2");
t.setDate(df.newXMLGregorianCalendar("2011-03-03T12:00:00+03:00"));
tl.add(t);
t = new Transaction();
t.setAcctNumber("3");
t.setDate(df.newXMLGregorianCalendar("2011-03-04T12:00:00+03:00"));
tl.add(t);
t = new Transaction();
t.setAcctNumber("4");
t.setDate(df.newXMLGregorianCalendar("2011-03-01T12:00:00+03:00"));
tl.add(t);
Collections.sort(tl, new TransactionDateComparator());
Assert.assertTrue(tl.get(0).getAcctNumber().equals("4"));
Assert.assertTrue(tl.get(1).getAcctNumber().equals("1"));
Assert.assertTrue(tl.get(2).getAcctNumber().equals("2"));
Assert.assertTrue(tl.get(3).getAcctNumber().equals("3"));
}
use of javax.xml.datatype.DatatypeConfigurationException in project OpenMEAP by OpenMEAP.
the class BankingService method submitTransfer.
public synchronized Error submitTransfer(String userName, String srcAcct, String destAcct, Date date, double amount) {
DatatypeFactory df = null;
try {
df = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException dce) {
throw new RuntimeException(dce);
}
Account src = null, dest = null;
src = findAccount(userName, srcAcct);
dest = findAccount(userName, destAcct);
if (src == null || dest == null) {
Error err = new Error();
err.setCode(ErrorType.PARAM_BAD);
err.setMessage("Could not find either the source or destination account.");
return err;
}
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(date.getTime());
submitTransfer(src, dest, df.newXMLGregorianCalendar(cal), amount);
return null;
}
use of javax.xml.datatype.DatatypeConfigurationException in project UVMS-ActivityModule-APP by UnionVMS.
the class BaseMapper method convertToXMLGregorianCalendar.
protected static XMLGregorianCalendar convertToXMLGregorianCalendar(Date dateTime, boolean includeTimeZone) {
XMLGregorianCalendar calendar = null;
try {
GregorianCalendar cal = new GregorianCalendar();
cal.setTimeInMillis(dateTime.getTime());
calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
if (!includeTimeZone) {
// If we do not want timeZone to be included, set this
calendar.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
}
} catch (DatatypeConfigurationException e) {
log.error(e.getMessage(), e);
}
return calendar;
}
use of javax.xml.datatype.DatatypeConfigurationException in project xades4j by luisgoncalves.
the class ToXmlCompleteRevocRefsConverter method convertIntoObjectTree.
@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlUnsignedPropertiesType xmlProps, Document doc) {
CompleteRevocationRefsData complRevocRefsData = (CompleteRevocationRefsData) propData;
// Only CRL refs are supported.
XmlCRLRefsType xmlCRLRefs = new XmlCRLRefsType();
List<XmlCRLRefType> xmlCRLRefsList = xmlCRLRefs.getCRLRef();
try {
for (CRLRef crlRef : complRevocRefsData.getCrlRefs()) {
XmlCRLIdentifierType xmlCrlId = new XmlCRLIdentifierType();
xmlCrlId.setIssueTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(crlRef.issueTime));
xmlCrlId.setIssuer(crlRef.issuerDN);
// May be null.
xmlCrlId.setNumber(crlRef.serialNumber);
XmlDigestAlgAndValueType xmlDigest = new XmlDigestAlgAndValueType();
XmlDigestMethodType xmlDigestMethod = new XmlDigestMethodType();
xmlDigestMethod.setAlgorithm(crlRef.digestAlgUri);
xmlDigest.setDigestValue(crlRef.digestValue);
xmlDigest.setDigestMethod(xmlDigestMethod);
XmlCRLRefType xmlCrlRef = new XmlCRLRefType();
xmlCrlRef.setCRLIdentifier(xmlCrlId);
xmlCrlRef.setDigestAlgAndValue(xmlDigest);
xmlCRLRefsList.add(xmlCrlRef);
}
} catch (DatatypeConfigurationException ex) {
throw new UnsupportedOperationException(ex.getMessage(), ex);
}
XmlCompleteRevocationRefsType xmlComplRevocRefs = new XmlCompleteRevocationRefsType();
// Only CRL refs are supported.
xmlComplRevocRefs.setCRLRefs(xmlCRLRefs);
xmlProps.getUnsignedSignatureProperties().setCompleteRevocationRefs(xmlComplRevocRefs);
}
Aggregations