Java 类javax.xml.datatype.DatatypeConfigurationException 实例源码

项目:FHIR-CQL-ODM-service    文件:FhirService.java   
private XMLGregorianCalendar getXMLGregorianCalendarNow()
        throws DatatypeConfigurationException {
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    XMLGregorianCalendar now = datatypeFactory
            .newXMLGregorianCalendar(gregorianCalendar);
    return now;
}
项目:oscm    文件:ResellerShareResultAssembler.java   
private Period preparePeriod(long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {

    Period period = new Period();

    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gc = new GregorianCalendar();

    // start date
    period.setStartDate(BigInteger.valueOf(periodStartTime));
    gc.setTimeInMillis(periodStartTime);
    period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    // end date
    period.setEndDate(BigInteger.valueOf(periodEndTime));
    gc.setTimeInMillis(periodEndTime);
    period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    return period;
}
项目:FHIR-CQL-ODM-service    文件:FhirService.java   
private ODM createODM(Map<String, Object> results, Integer project_id,
        Integer event_id, String instrument, String patientId)
        throws JAXBException, DatatypeConfigurationException {
    // List<ODMcomplexTypeDefinitionItemData> items =
    // OdmUtil.getOdmItems(studyODM);

    ODM studyODM = createOdmTemplate(project_id, event_id, instrument,
            patientId);
    List<ODMcomplexTypeDefinitionItemData> items = OdmUtil
            .getOdmGroupData(studyODM);
    for (String key : results.keySet()) {
        if (results.get(key) != null) { // do not add to response if null
            ODMcomplexTypeDefinitionItemData item = new ODMcomplexTypeDefinitionItemData();
            item.setItemOID(key);
            item.setValue(results.get(key).toString());
            items.add(item);
        }
    }

    return studyODM;
}
项目:openjdk-jdk10    文件:DurationTest.java   
@Test
public void testDurationMultiply() {
    int num = 5000; // millisends. 5 seconds
    int factor = 2;
    try {
        Duration dur = DatatypeFactory.newInstance().newDuration(num);
        if (dur.multiply(factor).getSeconds() != 10) {
            Assert.fail("duration.multiply() return wrong value");
        }
        // factor is 2*10^(-1)
        if (dur.multiply(new BigDecimal(new BigInteger("2"), 1)).getSeconds() != 1) {
            Assert.fail("duration.multiply() return wrong value");
        }
        if (dur.subtract(DatatypeFactory.newInstance().newDuration(1000)).multiply(new BigDecimal(new BigInteger("2"), 1)).getSeconds() != 0) {
            Assert.fail("duration.multiply() return wrong value");
        }
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }
}
项目:stroom-stats    文件:TestValueStatToAggregateFlatMapper.java   
private Statistics.Statistic buildStatistic() throws DatatypeConfigurationException {

        //use system time as class under test has logic based on system time
        ZonedDateTime time = ZonedDateTime.now(ZoneOffset.UTC);

        Statistics.Statistic statistic = StatisticsHelper.buildValueStatistic(
                time,
                10.5,
                StatisticsHelper.buildTagType(tag1, tag1val1),
                StatisticsHelper.buildTagType(tag2, tag2val1)
        );
        StatisticsHelper.addIdentifier(statistic, id1part1, id1part2);
        StatisticsHelper.addIdentifier(statistic, id2part1, id2part2);

        return statistic;
    }
项目:stroom-stats    文件:TestCountStatToAggregateFlatMapper.java   
private Statistics.Statistic buildStatistic() throws DatatypeConfigurationException {

        //use system time as class under test has logic based on system time
        ZonedDateTime time = ZonedDateTime.now(ZoneOffset.UTC);

        Statistics.Statistic statistic = StatisticsHelper.buildCountStatistic(
                time,
                10L,
                StatisticsHelper.buildTagType(tag1, tag1val1),
                StatisticsHelper.buildTagType(tag2, tag2val1)
        );
        StatisticsHelper.addIdentifier(statistic, id1part1, id1part2);
        StatisticsHelper.addIdentifier(statistic, id2part1, id2part2);

        return statistic;
    }
项目:openjdk-jdk10    文件:DurationTest.java   
@Test
public void testDurationAndCalendar3() {
    try {
        Calendar cal = new GregorianCalendar();
        cal.set(Calendar.SECOND, 59);
        DatatypeFactory.newInstance().newDuration(10000).addTo(cal);
        AssertJUnit.assertTrue("sec will be 9", cal.get(Calendar.SECOND) == 9);

        Date date = new Date();
        date.setSeconds(59);
        DatatypeFactory.newInstance().newDuration(10000).addTo(date);
        AssertJUnit.assertTrue("sec will be 9", date.getSeconds() == 9);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }
}
项目:oscm    文件:GregorianCalendars.java   
/**
 * 
 * @return An object of type XMLGregorianCalendar containing the current
 *         system time and date
 * @throws DatatypeConfigurationException
 *             If the instantiation of the DatatypeFactory fails
 */
public static XMLGregorianCalendar newXMLGregorianCalendarSystemTime()
        throws DatatypeConfigurationException {
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    XMLGregorianCalendar now = datatypeFactory
            .newXMLGregorianCalendar(gregorianCalendar);
    return now;
}
项目:openjdk-jdk10    文件:Bug6925410Test.java   
@Test
public void test() throws DatatypeConfigurationException {
    try {
        int times = 100;
        long start = System.currentTimeMillis();
        for (int i = 0; i < times; i++) {
            XMLReaderFactory.createXMLReader();
        }
        long end = System.currentTimeMillis();
        double speed = ((end - start));
        System.out.println(speed + "ms");
    } catch (Throwable e) {
        e.printStackTrace();
        Assert.fail(e.toString());
    }

}
项目:oscm    文件:BrokerShareResultAssembler.java   
void setPeriod(long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {
    this.periodEndTime = periodEndTime;

    Period period = new Period();

    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gc = new GregorianCalendar();

    // start date
    period.setStartDate(BigInteger.valueOf(periodStartTime));
    gc.setTimeInMillis(periodStartTime);
    period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    // end date
    period.setEndDate(BigInteger.valueOf(periodEndTime));
    gc.setTimeInMillis(periodEndTime);
    period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    result.setPeriod(period);
}
项目:oscm    文件:ResellerShareResultAssembler.java   
public ResellerRevenueShareResult build(Long resellerKey,
        long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {
    Invariants.assertNotNull(resellerKey);

    result = new ResellerRevenueShareResult();
    setOrganizationData(resellerKey);
    setResellerData(resellerKey);
    setPeriod(periodStartTime, periodEndTime);

    List<BillingResult> billingResults = sharesRetrievalService
            .loadBillingResultsForReseller(resellerKey, periodStartTime,
                    periodEndTime);
    for (BillingResult billingResult : billingResults) {
        currentBillingResult = billingResult;
        xmlSearch = newXmlSearch(currentBillingResult);
        addCurrency();
    }
    return result;
}
项目:oscm    文件:ResellerShareResultAssembler.java   
private void addService(Supplier supplier, long subscriptionKey)
        throws DatatypeConfigurationException {
    Set<Long> priceModelKeys = xmlSearch.findPriceModelKeys();
    for (Iterator<Long> iterator = priceModelKeys.iterator(); iterator
            .hasNext();) {
        pmKey = iterator.next();

        ProductHistory productHistory = sharesRetrievalService
                .loadProductOfVendor(subscriptionKey, pmKey, periodEndTime);
        Service service = supplier.getServiceByKey(productHistory
                .getObjKey());
        if (service == null) {
            service = buildService(productHistory);
            supplier.addService(service);
        }

        addSubscription(service, subscriptionKey);
        setServiceRevenue(service.getServiceRevenue());
        addServiceCustomerRevenue(service, subscriptionKey);
    }
}
项目:oscm    文件:ResellerShareResultAssembler.java   
private Subscription buildSubscription(long subscriptionKey)
        throws DatatypeConfigurationException {
    SubscriptionHistory subscriptionHistory = sharesRetrievalService
            .loadSubscriptionHistoryWithinPeriod(subscriptionKey,
                    periodEndTime);

    Subscription subscription = new Subscription();
    subscription.setKey(BigInteger.valueOf(subscriptionKey));
    subscription.setId(subscriptionHistory.getDataContainer()
            .getSubscriptionId());
    subscription.setBillingKey(BigInteger.valueOf(currentBillingResult
            .getKey()));
    subscription.setRevenue(currentBillingResult.getNetAmount());
    Period period = preparePeriod(
            this.currentBillingResult.getPeriodStartTime(),
            this.currentBillingResult.getPeriodEndTime());
    subscription.setPeriod(period);
    return subscription;
}
项目:oscm    文件:MpOwnerShareResultAssembler.java   
void setPeriod(long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {

    this.periodStartTime = periodStartTime;
    this.periodEndTime = periodEndTime;

    Period period = new Period();

    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gc = new GregorianCalendar();

    // start date
    period.setStartDate(BigInteger.valueOf(periodStartTime));
    gc.setTimeInMillis(periodStartTime);
    period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    // end date
    period.setEndDate(BigInteger.valueOf(periodEndTime));
    gc.setTimeInMillis(periodEndTime);
    period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    result.setPeriod(period);
}
项目:oscm    文件:SupplierShareResultAssembler.java   
/**
 * Iterates over all billing results.<br />
 * 
 * Shares are extracted price model by price model and are based on net
 * values.
 * 
 * @param supplierKey
 *            valid key of a supplier organization
 * @param periodStartTime
 *            start of a calendar month is expected
 * @param periodEndTime
 *            end of a calendar month is expected
 */
public SupplierRevenueShareResult build(Long supplierKey,
        long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {

    Invariants.assertNotNull(supplierKey);

    result = new SupplierRevenueShareResult();
    OrganizationHistory org = billingRetrievalService
            .loadLastOrganizationHistory(supplierKey);
    result.setOrganizationData(buildOrganizationData(org));
    setSupplierData(supplierKey);
    setPeriod(periodStartTime, periodEndTime);

    List<BillingResult> billingResults = billingRetrievalService
            .loadBillingResultsForSupplier(supplierKey, periodStartTime,
                    periodEndTime);
    for (BillingResult billingResult : billingResults) {
        currentBillingResult = billingResult;
        xmlSearch = newXmlSearch(currentBillingResult);
        addCurrency();
    }
    return result;
}
项目:oscm    文件:SupplierShareResultAssembler.java   
private Period preparePeriod(long periodStartTime, long periodEndTime)
        throws DatatypeConfigurationException {

    Period period = new Period();

    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gc = new GregorianCalendar();

    period.setStartDate(BigInteger.valueOf(periodStartTime));
    gc.setTimeInMillis(periodStartTime);
    period.setStartDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    period.setEndDate(BigInteger.valueOf(periodEndTime));
    gc.setTimeInMillis(periodEndTime);
    period.setEndDateIsoFormat(df.newXMLGregorianCalendar(gc).normalize());

    return period;
}
项目:oscm    文件:SupplierShareResultAssembler.java   
private void addMarketplace(Currency currency)
        throws DatatypeConfigurationException {
    long subscriptionKey = currentBillingResult.getSubscriptionKey()
            .longValue();
    MarketplaceHistory marketplaceHistory = billingRetrievalService
            .loadMarketplaceHistoryBySubscriptionKey(subscriptionKey,
                    periodEndTime);
    Marketplace marketplace = currency.getMarketplace(marketplaceHistory
            .getObjKey());
    if (marketplace == null) {
        marketplace = buildMarketplace(marketplaceHistory);
        currency.addMarketplace(marketplace);
    }

    addService(marketplace, subscriptionKey);
}
项目:oscm    文件:SupplierShareResultAssembler.java   
private void addService(Marketplace marketplace, long subscriptionKey)
        throws DatatypeConfigurationException {

    Set<Long> priceModelKeys = xmlSearch.findPriceModelKeys();
    for (Iterator<Long> iterator = priceModelKeys.iterator(); iterator
            .hasNext();) {
        pmKey = iterator.next();
        ProductHistory prd = billingRetrievalService.loadProductOfVendor(
                subscriptionKey, pmKey, periodEndTime);
        Service service = marketplace.getServiceByKey(prd.getObjKey());
        if (service == null) {
            service = buildService(marketplace, prd);
            marketplace.addService(service);
        }
        addSubscription(service, subscriptionKey);
        addServiceCustomerRevenue(service, subscriptionKey);
    }
}
项目:oscm    文件:SupplierShareResultAssembler.java   
private void addSubscription(Service service, long subscriptionKey)
        throws DatatypeConfigurationException {
    BigDecimal serviceRevenue = DiscountCalculator.calculateServiceRevenue(
            xmlSearch, pmKey);
    if (service.getModel().equals(OfferingType.RESELLER.name())) {
        SubscriptionsRevenue revenue = service
                .retrieveSubscriptionsRevenue();
        revenue.sumUp(serviceRevenue);
    } else {
        Subscription subscription = service
                .getSubscriptionByKey(subscriptionKey);
        if (subscription != null) {
            // Billing result contains multiple price models for the same
            // service.This may occur if a subscription is upgraded to a new
            // service and downgraded again to the original service in the
            // same billing period.
            subscription.sumUpRevenue(serviceRevenue);
        } else {
            subscription = buildSubscription(subscriptionKey,
                    serviceRevenue);
            service.addSubscription(subscription);
        }
    }
}
项目:oscm    文件:SupplierShareResultAssembler.java   
private Subscription buildSubscription(long subscriptionKey,
        BigDecimal serviceRevenue) throws DatatypeConfigurationException {

    SubscriptionHistory subscriptionHistory = billingRetrievalService
            .loadSubscriptionHistoryWithinPeriod(subscriptionKey,
                    periodEndTime);

    Subscription subscription = new Subscription();
    subscription.setKey(BigInteger.valueOf(subscriptionKey));
    subscription.setId(subscriptionHistory.getDataContainer()
            .getSubscriptionId());
    subscription.setBillingKey(BigInteger.valueOf(currentBillingResult
            .getKey()));
    subscription.setRevenue(serviceRevenue);
    Period period = preparePeriod(
            this.currentBillingResult.getPeriodStartTime(),
            this.currentBillingResult.getPeriodEndTime());
    subscription.setPeriod(period);
    return subscription;
}
项目:oscm    文件:AuthnRequestGenerator.java   
public JAXBElement<AuthnRequestType> generateAuthnRequest()
        throws DatatypeConfigurationException {

    org.oscm.saml2.api.model.protocol.ObjectFactory protocolObjFactory;
    protocolObjFactory = new org.oscm.saml2.api.model.protocol.ObjectFactory();
    org.oscm.saml2.api.model.assertion.ObjectFactory assertionObjFactory;
    assertionObjFactory = new org.oscm.saml2.api.model.assertion.ObjectFactory();

    NameIDType issuer = assertionObjFactory.createNameIDType();
    issuer.setValue(this.issuer);

    AuthnRequestType authnRequest = protocolObjFactory
            .createAuthnRequestType();
    authnRequest.setID(requestId);
    authnRequest.setVersion("2.0");
    authnRequest.setIssueInstant(GregorianCalendars
            .newXMLGregorianCalendarSystemTime());
    Integer acsIndex = isHttps.booleanValue() ? HTTPS_INDEX : HTTP_INDEX;
    authnRequest.setAssertionConsumerServiceIndex(acsIndex);
    authnRequest.setIssuer(issuer);

    JAXBElement<AuthnRequestType> authnRequestJAXB = protocolObjFactory
            .createAuthnRequest(authnRequest);

    return authnRequestJAXB;
}
项目:OpenJSharp    文件:DatatypeConverterImpl.java   
public static DatatypeFactory getDatatypeFactory() {
    ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
        public ClassLoader run() {
            return Thread.currentThread().getContextClassLoader();
        }
    });
    DatatypeFactory df = DF_CACHE.get(tccl);
    if (df == null) {
        synchronized (DatatypeConverterImpl.class) {
            df = DF_CACHE.get(tccl);
            if (df == null) { // to prevent multiple initialization
                try {
                    df = DatatypeFactory.newInstance();
                } catch (DatatypeConfigurationException e) {
                    throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e);
                }
                DF_CACHE.put(tccl, df);
            }
        }
    }
    return df;
}
项目:OperatieBRP    文件:VrijBerichtClientServiceImpl.java   
private void vulStuurgegevens(final VrijBericht vrijBericht, final VrijBerichtStuurVrijBericht verzoek, final PartijCode zendendePartij)
        throws DatatypeConfigurationException {
    final GroepBerichtStuurgegevens stuurgegevens = objectFactory.createGroepBerichtStuurgegevens();
    stuurgegevens.setCommunicatieID(UUID.randomUUID().toString());
    final SysteemNaam zendendeSysteem = new SysteemNaam();
    final Referentienummer referentieNummer = new Referentienummer();
    final DatumTijd tijdstipVerzending = new DatumTijd();
    zendendeSysteem.setValue("BRP");
    referentieNummer.setValue(UUID.randomUUID().toString());
    final GregorianCalendar c = new GregorianCalendar();
    final XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    c.setTime(vrijBericht.getTijdstipRegistratie());
    tijdstipVerzending.setValue(xmlDate);
    stuurgegevens.setZendendePartij(objectFactory.createGroepBerichtStuurgegevensZendendePartij(zendendePartij));
    stuurgegevens.setZendendeSysteem(objectFactory.createGroepBerichtStuurgegevensZendendeSysteem(zendendeSysteem));
    stuurgegevens.setReferentienummer(objectFactory.createGroepBerichtStuurgegevensReferentienummer(referentieNummer));
    stuurgegevens.setTijdstipVerzending(objectFactory.createGroepBerichtStuurgegevensTijdstipVerzending(tijdstipVerzending));
    verzoek.setStuurgegevens(objectFactory.createObjecttypeBerichtStuurgegevens(stuurgegevens));
}
项目:jdk8u-jdk    文件:TestXMLGregorianCalendarTimeZone.java   
private static void test(int offsetMinutes)
        throws DatatypeConfigurationException {
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().
            newXMLGregorianCalendar();
    calendar.setTimezone(60 + offsetMinutes);
    TimeZone timeZone = calendar.getTimeZone(DatatypeConstants.FIELD_UNDEFINED);
    String expected = (offsetMinutes < 10 ? "GMT+01:0" : "GMT+01:")
            + offsetMinutes;
    if (!timeZone.getID().equals(expected)) {
        throw new RuntimeException("Test failed: expected timezone: " +
                expected + " Actual: " + timeZone.getID());
    }
}
项目:openjdk-jdk10    文件:CalendarDuration1243Test.java   
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "2006-11-22T00:00:00.0+01:02";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "XMLGregCal:" + cal.toString() );
        System.out.println( "GregCal:" + cal.toGregorianCalendar() );
        String toGCal = cal.toGregorianCalendar().toString();
        if (toGCal.indexOf("GMT+12:00") > -1) {
            throw new RuntimeException("Expected GMT+01:02");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
项目:openjdk-jdk10    文件:CalendarDuration1097Test.java   
/**
 * main method.
 *
 * @param args Standard args.
 */
public static void main(String[] args) {
    try {
        String dateTimeString = "0001-01-01T00:00:00.0000000-05:00";
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = dtf.newXMLGregorianCalendar( dateTimeString );
        System.out.println( "Expected: 0001-01-01T00:00:00.0000000-05:00");
        System.out.println( "Actual:" + cal.toString() );
        System.out.println( "toXMLFormat:" + cal.toXMLFormat() );
        String test = cal.toString();
        if (test.indexOf("E-7") > -1) {
            throw new RuntimeException("Expected: 0001-01-01T00:00:00.0000000-05:00");
        }
    } catch (DatatypeConfigurationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}
项目:openjdk-jdk10    文件:DatatypeConverterImpl.java   
public static DatatypeFactory getDatatypeFactory() {
    ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
        public ClassLoader run() {
            return Thread.currentThread().getContextClassLoader();
        }
    });
    DatatypeFactory df = DF_CACHE.get(tccl);
    if (df == null) {
        synchronized (DatatypeConverterImpl.class) {
            df = DF_CACHE.get(tccl);
            if (df == null) { // to prevent multiple initialization
                try {
                    df = DatatypeFactory.newInstance();
                } catch (DatatypeConfigurationException e) {
                    throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e);
                }
                DF_CACHE.put(tccl, df);
            }
        }
    }
    return df;
}
项目:weixinpay    文件:DateUtil.java   
public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date date) {
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(date);
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    XMLGregorianCalendar xt = null;
    try {
        xt = DatatypeFactory.newInstance().newXMLGregorianCalendar(year, month + 1, day, 0, 0, 0, 0, 0);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    return xt;
}
项目:openjdk-jdk10    文件:DurationTest.java   
@Test
public void testDurationSubtract() {
    try {
        Duration bigDur = DatatypeFactory.newInstance().newDuration(20000);
        Duration smallDur = DatatypeFactory.newInstance().newDuration(10000);
        if (smallDur.subtract(bigDur).getSign() != -1) {
            Assert.fail("smallDur.subtract(bigDur).getSign() is not -1");
        }
        if (bigDur.subtract(smallDur).getSign() != 1) {
            Assert.fail("bigDur.subtract(smallDur).getSign() is not 1");
        }
        if (smallDur.subtract(smallDur).getSign() != 0) {
            Assert.fail("smallDur.subtract(smallDur).getSign() is not 0");
        }
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }
}
项目:openjdk-jdk10    文件:DurationTest.java   
private void newDurationDayTimeTester(boolean isPositive, boolean normalizedIsPositive, BigInteger years, BigInteger normalizedYears, BigInteger months,
        BigInteger normalizedMonths, BigInteger days, BigInteger normalizedDays, BigInteger hours, BigInteger normalizedHours, BigInteger minutes,
        BigInteger normalizedMinutes, BigDecimal seconds, BigDecimal normalizedSeconds, long durationInMilliSeconds, long normalizedDurationInMilliSeconds,
        String lexicalRepresentation, String normalizedLexicalRepresentation) {

    DatatypeFactory datatypeFactory = null;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException ex) {
        ex.printStackTrace();
        Assert.fail(ex.toString());
    }

    // create 4 dayTime Durations using the 4 different constructors

    Duration durationDayTimeBigInteger = datatypeFactory.newDurationDayTime(isPositive, days, hours, minutes, seconds.toBigInteger());
    durationAssertEquals(durationDayTimeBigInteger, DatatypeConstants.DURATION_DAYTIME, normalizedIsPositive, normalizedYears.intValue(),
            normalizedMonths.intValue(), normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(),
            normalizedDurationInMilliSeconds, normalizedLexicalRepresentation);

    /*
     * Duration durationDayTimeInt = datatypeFactory.newDurationDayTime(
     * isPositive, days.intValue(), hours.intValue(), minutes.intValue(),
     * seconds.intValue()); Duration durationDayTimeMilliseconds =
     * datatypeFactory.newDurationDayTime( durationInMilliSeconds); Duration
     * durationDayTimeLexical = datatypeFactory.newDurationDayTime(
     * lexicalRepresentation);
     * Duration durationYearMonthBigInteger =
     * datatypeFactory.newDurationYearMonth( isPositive, years, months);
     * Duration durationYearMonthInt = datatypeFactory.newDurationYearMonth(
     * isPositive, years.intValue(), months.intValue()); Duration
     * durationYearMonthMilliseconds = datatypeFactory.newDurationYearMonth(
     * durationInMilliSeconds); Duration durationYearMonthLexical =
     * datatypeFactory.newDurationYearMonth( lexicalRepresentation) ;
     */

}
项目:rapidminer    文件:XMLTools.java   
public static XMLGregorianCalendar getXMLGregorianCalendar(Date date) {
    if (date == null) {
        return null;
    }
    // Calendar calendar = Calendar.getInstance();
    // calendar.setTimeInMillis(date.getTime());
    DatatypeFactory datatypeFactory;
    try {
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException e) {
        throw new RuntimeException("Failed to create XMLGregorianCalendar: " + e, e);
    }
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(date);
    return datatypeFactory.newXMLGregorianCalendar(c);
    //
    // XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar();
    // xmlGregorianCalendar.setYear(calendar.get(Calendar.YEAR));
    // xmlGregorianCalendar.setMonth(calendar.get(Calendar.MONTH) + 1);
    // xmlGregorianCalendar.setDay(calendar.get(Calendar.DAY_OF_MONTH));
    // xmlGregorianCalendar.setHour(calendar.get(Calendar.HOUR_OF_DAY));
    // xmlGregorianCalendar.setMinute(calendar.get(Calendar.MINUTE));
    // xmlGregorianCalendar.setSecond(calendar.get(Calendar.SECOND));
    // xmlGregorianCalendar.setMillisecond(calendar.get(Calendar.MILLISECOND));
    // //
    // xmlGregorianCalendar.setTimezone(calendar.get(((Calendar.DST_OFFSET)+calendar.get(Calendar.ZONE_OFFSET))/(60*1000)));
    // return xmlGregorianCalendar;
}
项目:cim-processor    文件:ModelParser.java   
public AppliedOutages applyOutages(Calendar calendar, boolean assumeConnected) {
    appliedOutages = ModelParser.applyOutages(calendar, rdfModel, assumeConnected);
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    gregorianCalendar.setTime(appliedOutages.getEffectiveEnd().getTime());
    try {
        DatatypeFactory factory = DatatypeFactory.newInstance();
        endDate = factory.newXMLGregorianCalendar(gregorianCalendar);
        Duration oneSecond = factory.newDuration("PT1S");
        endDate.add(oneSecond);
    } catch (DatatypeConfigurationException e) {
        // do nothing
    }
    return appliedOutages;
}
项目:FHIR-CQL-ODM-service    文件:FhirService.java   
private ODM createOdmTemplate(Integer project_id, Integer event_id,
        String instrument, String patientId)
        throws DatatypeConfigurationException {
    ODM studyTemplate = new ODM();
    studyTemplate.setODMVersion("1.3.2");
    studyTemplate.setCreationDateTime(getXMLGregorianCalendarNow());

    ODMcomplexTypeDefinitionClinicalData clinicalData = new ODMcomplexTypeDefinitionClinicalData();
    studyTemplate.getClinicalData().add(clinicalData);
    clinicalData.setStudyOID(project_id.toString());
    ODMcomplexTypeDefinitionSubjectData subjectData = new ODMcomplexTypeDefinitionSubjectData();
    clinicalData.getSubjectData().add(subjectData);
    subjectData.setSubjectKey(patientId);
    ODMcomplexTypeDefinitionStudyEventData studyEventData = new ODMcomplexTypeDefinitionStudyEventData();
    subjectData.getStudyEventData().add(studyEventData);
    if (event_id != null) {
        studyEventData.setStudyEventOID(event_id.toString());
    }
    ODMcomplexTypeDefinitionFormData formData = new ODMcomplexTypeDefinitionFormData();
    studyEventData.getFormData().add(formData);
    formData.setFormOID(instrument);
    ODMcomplexTypeDefinitionItemGroupData itemGroupData = new ODMcomplexTypeDefinitionItemGroupData();
    formData.getItemGroupData().add(itemGroupData);
    itemGroupData.setItemGroupOID(instrument);

    return studyTemplate;
}
项目:camunda-util-demo-data-generator    文件:TimeAwareDemoGenerator.java   
public TimeAwareDemoGenerator(ProcessEngine engine, ProcessApplicationReference originalProcessApplicationReference,
    ProcessApplicationReference simulatingProcessApplicationReference) {
  this.engine = engine;
  this.originalProcessApplication = originalProcessApplicationReference;
  this.simulatingProcessApplication = simulatingProcessApplicationReference;
  try {
    datatypeFactory = DatatypeFactory.newInstance();
  } catch (DatatypeConfigurationException e) {
    throw new RuntimeException(e);
  }
}
项目:stroom-stats    文件:TestStatisticValidator.java   
private StatisticWrapper buildBasicStatWrapper() throws DatatypeConfigurationException {
    ZonedDateTime time = ZonedDateTime.of(
            LocalDateTime.of(2017, 2, 27, 10, 50, 30),
            ZoneOffset.UTC);
    String tag1 = "tag1";
    String tag2 = "tag2";
    EventStoreTimeIntervalEnum interval = EventStoreTimeIntervalEnum.MINUTE;
    StatisticType statisticType = StatisticType.COUNT;

    String statName = "MyStat";
    Statistics.Statistic statistic = StatisticsHelper.buildCountStatistic(
            time,
            1L,
            StatisticsHelper.buildTagType(tag1, tag1 + "val1"),
            StatisticsHelper.buildTagType(tag2, tag2 + "val1")
    );

    MockStatisticConfiguration statConfig = new MockStatisticConfiguration()
            .setUuid(statUuid)
            .setName(statName)
            .setStatisticType(statisticType)
            .setRollUpType(StatisticRollUpType.ALL)
            .addFieldName(tag1)
            .addFieldName(tag2)
            .setPrecision(interval);

    return new StatisticWrapper(statistic, Optional.of(statConfig));
}
项目:stroom-stats    文件:StatisticsHelper.java   
private static Statistics.Statistic buildStatistic(ZonedDateTime time, TagType... tagValues) {
    ObjectFactory objectFactory = new ObjectFactory();
    Statistics.Statistic statistic = objectFactory.createStatisticsStatistic();
    Statistics.Statistic.Tags tagsObj = new Statistics.Statistic.Tags();
    tagsObj.getTag().addAll(Arrays.asList(tagValues));
    statistic.setTags(tagsObj);
    GregorianCalendar gregorianCalendar = GregorianCalendar.from(time);
    try {
        statistic.setTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar));
    } catch (DatatypeConfigurationException e) {
        throw new RuntimeException(String.format("Error converting time %s to a gregorian calendar", time), e);
    }
    return statistic;
}
项目:alfresco-repository    文件:CMISConnector.java   
private String convertAspectPropertyValue(Object value)
{
    if (value instanceof Date)
    {
        GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
        cal.setTime((Date) value);
        value = cal;
    }

    if (value instanceof GregorianCalendar)
    {
        DatatypeFactory df;
        try
        {
            df = DatatypeFactory.newInstance();
        }
        catch (DatatypeConfigurationException e)
        {
            throw new IllegalArgumentException("Aspect conversation exception: " + e.getMessage(), e);
        }
        return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat();
    }

    // MNT-12496 MNT-15044
    // Filter for AtomPub and Web services bindings only. Browser/json binding already encodes.
    if (AlfrescoCmisServiceCall.get() != null &&
            (CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) ||
             CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding())))
    {
        return filterXmlRestrictedCharacters(value.toString());
    }
    else
    {
        return value.toString();
    }
}
项目:the-vigilantes    文件:Value.java   
public void setDateTime(GregorianCalendar value) throws DatatypeConfigurationException {
    if (this.dtf == null) {
        this.dtf = DatatypeFactory.newInstance();
    }
    this.objValue = this.dtf.newXMLGregorianCalendar(value);
    this.objType = TYPE_dateTime_iso8601;
}
项目:the-vigilantes    文件:Value.java   
public void setDateTime(String value) throws DatatypeConfigurationException {
    if (this.dtf == null) {
        this.dtf = DatatypeFactory.newInstance();
    }
    this.objValue = this.dtf.newXMLGregorianCalendar(value);
    this.objType = TYPE_dateTime_iso8601;
}
项目:xitk    文件:XmlUtil.java   
public static XMLGregorianCalendar getXmlDate(Date dateAndTime) {
    ParamUtil.requireNonNull("dateAndTime", dateAndTime);
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTimeZone(UTC);
    cal.setTime(dateAndTime);

    try {
        XMLGregorianCalendar ret = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
        ret.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
        return ret;
    } catch (DatatypeConfigurationException ex) {
        return null;
    }
}