Search in sources :

Example 51 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)

Example 52 with DatatypeConfigurationException

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"));
}
Also used : DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory) ArrayList(java.util.ArrayList)

Example 53 with DatatypeConfigurationException

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;
}
Also used : DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 54 with DatatypeConfigurationException

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 55 with DatatypeConfigurationException

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);
}
Also used : XmlCRLIdentifierType(xades4j.xml.bind.xades.XmlCRLIdentifierType) XmlDigestAlgAndValueType(xades4j.xml.bind.xades.XmlDigestAlgAndValueType) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) XmlCRLRefType(xades4j.xml.bind.xades.XmlCRLRefType) XmlCompleteRevocationRefsType(xades4j.xml.bind.xades.XmlCompleteRevocationRefsType) CRLRef(xades4j.properties.data.CRLRef) XmlDigestMethodType(xades4j.xml.bind.xmldsig.XmlDigestMethodType) XmlCRLRefsType(xades4j.xml.bind.xades.XmlCRLRefsType) CompleteRevocationRefsData(xades4j.properties.data.CompleteRevocationRefsData)

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