Search in sources :

Example 6 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory in project cxf by apache.

the class SubscriptionManagerImpl method grantExpiration.

/**
 * Decide what expiration time to grant to the subscription, if
 * the client did not specify any particular wish for subscription length.
 */
public XMLGregorianCalendar grantExpiration() {
    try {
        // by default, we grant an expiration time of 2 years
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar granted = factory.newXMLGregorianCalendar(new GregorianCalendar());
        granted.add(factory.newDurationYearMonth(true, 2, 0));
        return granted;
    } catch (DatatypeConfigurationException ex) {
        throw new Error(ex);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 7 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory in project Payara by payara.

the class ScheduledTimerNode method setElementValue.

@Override
public void setElementValue(XMLElement element, String value) {
    if (EjbTagNames.TIMER_START.equals(element.getQName())) {
        try {
            DatatypeFactory dFactory = DatatypeFactory.newInstance();
            XMLGregorianCalendar xmlGreg = dFactory.newXMLGregorianCalendar(value);
            GregorianCalendar cal = xmlGreg.toGregorianCalendar();
            descriptor.setStart(cal.getTime());
        } catch (Exception e) {
            DOLUtils.getDefaultLogger().warning(e.getMessage());
        }
    } else if (EjbTagNames.TIMER_END.equals(element.getQName())) {
        try {
            DatatypeFactory dFactory = DatatypeFactory.newInstance();
            XMLGregorianCalendar xmlGreg = dFactory.newXMLGregorianCalendar(value);
            GregorianCalendar cal = xmlGreg.toGregorianCalendar();
            descriptor.setEnd(cal.getTime());
        } catch (Exception e) {
            DOLUtils.getDefaultLogger().warning(e.getMessage());
        }
    } else {
        super.setElementValue(element, value);
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeFactory(javax.xml.datatype.DatatypeFactory) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 8 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory in project jackson-module-afterburner by FasterXML.

the class JavaxTypesTest method testGregorianCalendar.

public void testGregorianCalendar() throws Exception {
    DatatypeFactory f = DatatypeFactory.newInstance();
    XMLGregorianCalendar in = f.newXMLGregorianCalendar();
    in.setYear(2014);
    in.setMonth(3);
    String json = MAPPER.writeValueAsString(in);
    assertNotNull(json);
    XMLGregorianCalendar out = MAPPER.readValue(json, XMLGregorianCalendar.class);
    assertNotNull(out);
    // minor sanity check
    assertEquals(in.getYear(), out.getYear());
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeFactory(javax.xml.datatype.DatatypeFactory)

Example 9 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory 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 10 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory 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)

Aggregations

DatatypeFactory (javax.xml.datatype.DatatypeFactory)22 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)17 GregorianCalendar (java.util.GregorianCalendar)10 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)9 Date (java.util.Date)7 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)5 SubscriptionFilterVisitor (ddf.catalog.pubsub.internal.SubscriptionFilterVisitor)5 ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)5 GeospatialPredicate (ddf.catalog.pubsub.predicate.GeospatialPredicate)5 Predicate (ddf.catalog.pubsub.predicate.Predicate)5 HashMap (java.util.HashMap)5 FilterTransformer (org.geotools.filter.FilterTransformer)5 Test (org.junit.Test)5 Filter (org.opengis.filter.Filter)5 Event (org.osgi.service.event.Event)5 ArrayList (java.util.ArrayList)3 FreeBusyResponseType (com.microsoft.schemas.exchange.services._2006.messages.FreeBusyResponseType)1 GetUserAvailabilityRequestType (com.microsoft.schemas.exchange.services._2006.messages.GetUserAvailabilityRequestType)1 GetUserAvailabilityResponseType (com.microsoft.schemas.exchange.services._2006.messages.GetUserAvailabilityResponseType)1 ArrayOfMailboxData (com.microsoft.schemas.exchange.services._2006.types.ArrayOfMailboxData)1