Example usage for javax.xml.datatype DatatypeConfigurationException printStackTrace

List of usage examples for javax.xml.datatype DatatypeConfigurationException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.datatype DatatypeConfigurationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static XMLGregorianCalendar getXMLGregorianCalendarTimestamp() {
    try {/* w w w .j  av a2  s. c o m*/
        DatatypeFactory dtf = DatatypeFactory.newInstance();
        GregorianCalendar gc = new GregorianCalendar();
        return dtf.newXMLGregorianCalendar(gc);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static XMLGregorianCalendar getXmlGregorianCalendarFromDate(Date date) {

    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(date);/*w ww .  ja v a2s .c  o m*/

    XMLGregorianCalendar f = null;
    try {
        f = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    return f;
}

From source file:Main.java

public static XMLGregorianCalendar parse(String time) {

    XMLGregorianCalendar date = null;
    try {//from ww w  .  ja  v  a2 s  . c  o m
        if (time.indexOf(":") < 0) {
            time = time + "T00:00:00";
        }
        date = DatatypeFactory.newInstance().newXMLGregorianCalendar(time);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    return date;
}

From source file:Main.java

public static XMLGregorianCalendar parse(String time, int timezone) {
    XMLGregorianCalendar date = null;
    try {/*w  w w.  j ava  2s  . c  o  m*/
        if (time.indexOf(":") < 0) {
            time = time + "T00:00:00";
        }
        date = DatatypeFactory.newInstance().newXMLGregorianCalendar(time);
        date.setTimezone(timezone);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    return date;
}

From source file:Main.java

public static XMLGregorianCalendar parse(long time, int timezone) {
    GregorianCalendar cal = new GregorianCalendar();

    cal.setTimeInMillis(time);/*  w  w  w.  j  a v  a 2s  . c  om*/
    XMLGregorianCalendar xCal = null;
    try {
        xCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
        xCal.setTimezone(timezone);
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    return xCal;
}

From source file:com.qubit.solution.fenixedu.integration.cgd.services.form43.CgdForm43Sender.java

private static Person createPerson(org.fenixedu.academic.domain.Person person) {
    Person personData = new Person();

    executeIfAllowed(person, CgdAuthorizationCodes.BASIC_INFO, () -> personData.setName(person.getName()));
    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_EMAIL, () -> personData
            .setEmail(objectFactory.createPersonEmail(person.getInstitutionalEmailAddressValue())));
    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_GENDER, () -> personData
            .setGenderCode(objectFactory.createPersonGenderCode(getCodeForGender(person.getGender()))));

    YearMonthDay dateOfBirthYearMonthDay = person.getDateOfBirthYearMonthDay();
    if (dateOfBirthYearMonthDay != null) {
        executeIfAllowed(person, CgdAuthorizationCodes.BASIC_INFO, () -> {
            try {
                personData.setBirthDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(
                        dateOfBirthYearMonthDay.toDateTimeAtMidnight().toGregorianCalendar()));
            } catch (DatatypeConfigurationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }/*from  w ww.  j a va  2 s.com*/
        });
    }
    executeIfAllowed(person, CgdAuthorizationCodes.BASIC_INFO, () -> personData
            .setFiscalNumber(objectFactory.createPersonFiscalNumber(person.getSocialSecurityNumber())));

    PersonalIngressionData personalIngressionDataByExecutionYear = person.getStudent()
            .getPersonalIngressionDataByExecutionYear(ExecutionYear.readCurrentExecutionYear());
    if (personalIngressionDataByExecutionYear != null) {
        org.fenixedu.academic.domain.person.MaritalStatus maritalStatus = personalIngressionDataByExecutionYear
                .getMaritalStatus();
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_MARITAL_STATUS,
                () -> personData.setMaritalStatusCode(
                        objectFactory.createPersonMaritalStatusCode(getCodeForMaritalStatus(maritalStatus))));

    }

    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_FATHER_NAME, () -> personData
            .setFather(objectFactory.createPersonFather(getShortNameFor(person.getNameOfFather()))));

    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_MOTHER_NAME, () -> personData
            .setMother(objectFactory.createPersonMother(getShortNameFor(person.getNameOfMother()))));

    if (person.getCountryOfBirth() != null) {
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_BIRTH_COUNTRY,
                () -> personData.setPlaceOfBirthCountryCode(objectFactory
                        .createPersonPlaceOfBirthCountryCode(person.getCountryOfBirth().getCode())));
    }

    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_BIRTH_DISTRICT,
            () -> personData.setPlaceOfBirthDistrict(
                    objectFactory.createPersonPlaceOfBirthDistrict(person.getDistrictOfBirth())));

    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_BIRTH_COUNTY,
            () -> personData.setPlaceOfBirthCounty(
                    objectFactory.createPersonPlaceOfBirthCounty(person.getDistrictSubdivisionOfBirth())));

    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_BIRTH_PARISH, () -> personData
            .setPlaceOfBirthParish(objectFactory.createPersonPlaceOfBirthParish(person.getParishOfBirth())));

    ArrayOfstring nationality = new ArrayOfstring();
    nationality.getString().add(person.getCountry().getCode());
    Country countryOfResidence = person.getCountryOfResidence();

    executeIfAllowed(person, CgdAuthorizationCodes.BASIC_INFO, () -> {
        personData.setNationalities(nationality);
        if (countryOfResidence != null) {
            personData.setCountryOfResidenceCode(
                    objectFactory.createPersonCountryOfResidenceCode(countryOfResidence.getCode()));
        } else {
            personData.setCountryOfResidenceCode(objectFactory.createPersonCountryOfResidenceCode("PT"));
        }
    });

    PhysicalAddress defaultPhysicalAddress = person.getDefaultPhysicalAddress();
    if (defaultPhysicalAddress != null) {
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_ADDRESS_PLACE, () -> {
            personData.setAddress(objectFactory.createPersonAddress(defaultPhysicalAddress.getAddress()));
            personData.setPlace(objectFactory.createPersonPlace(defaultPhysicalAddress.getArea()));
        });
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_ADDRESS_POSTAL_CODE, () -> personData
                .setPostalCode(objectFactory.createPersonPostalCode(defaultPhysicalAddress.getAreaCode())));
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_ADDRESS_DISTRICT,
                () -> personData.setDistrict(
                        objectFactory.createPersonDistrict(defaultPhysicalAddress.getDistrictOfResidence())));
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_ADDRESS_POSTAL_COUNTY,
                () -> personData.setCounty(objectFactory
                        .createPersonCounty(defaultPhysicalAddress.getDistrictSubdivisionOfResidence())));
        executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_ADDRESS_POSTAL_PARISH, () -> personData
                .setParish(objectFactory.createPersonParish(defaultPhysicalAddress.getParishOfResidence())));
    }

    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_PHONE, () -> personData.setPhone(
            objectFactory.createPersonPhone(getPhoneNumberWithoutCountryCode(person.getDefaultPhoneNumber()))));
    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_MOBILE_PHONE,
            () -> personData.setMobilePhone(objectFactory.createPersonMobilePhone(
                    getPhoneNumberWithoutCountryCode(person.getDefaultMobilePhoneNumber()))));

    IdentificationCard card = new IdentificationCard();

    // skipping issuer
    String codeForDocumentType = getCodeForDocumentType(person.getIdDocumentType());
    if (codeForDocumentType != null) {
        card.setTypeCode(objectFactory.createIdentificationCardTypeCode(codeForDocumentType));
    }
    card.setNumber(person.getDocumentIdNumber());
    // skipping issuer country code
    executeIfAllowed(person, CgdAuthorizationCodes.EXTENDED_INFO_ID_CARD_EXPIRATION_DATE, () -> {
        try {
            YearMonthDay expirationDateOfDocumentIdYearMonthDay = person
                    .getExpirationDateOfDocumentIdYearMonthDay();
            if (expirationDateOfDocumentIdYearMonthDay != null) {
                card.setExpirationDate(objectFactory.createIdentificationCardExpirationDate(DatatypeFactory
                        .newInstance().newXMLGregorianCalendar(expirationDateOfDocumentIdYearMonthDay
                                .toDateTimeAtMidnight().toGregorianCalendar())));
            }
        } catch (DatatypeConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    });
    personData.setIdentificationCard(objectFactory.createIdentificationCard(card));

    return personData;
}

From source file:com.himanshu.um.impl.user.db.dao.UserDaoTest.java

@Test
public void createUser() throws UserCreationException, DatatypeConfigurationException, InterruptedException {
    ApplicationContext context = new ClassPathXmlApplicationContext("um-spring.xml");

    IManager manager = context.getBean(DatabaseManagerImpl.class);
    com.himanshu.um.api.model.User user = new com.himanshu.um.api.model.User();
    user.setUsername("himanshu");
    user.setPassword("password");
    user.setStatus(true);/* w w  w .  j av  a 2 s .  co m*/
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTimeInMillis(new Date().getTime());
    try {
        user.setCreatedDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
        throw e;
    }

    Thread.sleep(3000); //3 seconds sleep to demonstrate last modified date lag

    cal.setTimeInMillis(new Date().getTime());
    try {
        user.setLastModifiedDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
        throw e;
    }

    manager.addNewUser(user);
}

From source file:com.headstrong.npi.raas.Utils.java

public static CmAttributeDate getCmAttrDate(String dateStr) {
    if (null != dateStr && !dateStr.trim().isEmpty()) {
        Date date = DateConversion.getDateFromString(dateStr);
        if (null != date) {
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTime(date);/*from  w  w  w  .  java 2s  .  c  om*/
            XMLGregorianCalendar xmlGregorianCalendar;
            try {
                xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
            } catch (DatatypeConfigurationException e) {
                e.printStackTrace();
                return null;
            }
            CmAttributeDate cmAttributeDate = new CmAttributeDate();
            cmAttributeDate.setValue(xmlGregorianCalendar);

            return cmAttributeDate;
        }
    }
    return null;
}

From source file:com.headstrong.npi.raas.Utils.java

public static CmAttributeDateMonthDay getCmAttrDateMonthDay(String monthDayStr) {
    if (null != monthDayStr && !monthDayStr.trim().isEmpty()) {
        Date date = DateConversion.getDateFromMmDString(monthDayStr);
        if (null != date) {
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTime(date);/*  www . j  ava  2  s  .c  o  m*/
            XMLGregorianCalendar xmlGregorianCalendar;
            try {
                xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
                xmlGregorianCalendar.setMonth(cal.get(Calendar.MONTH) + 1);
                xmlGregorianCalendar.setDay(cal.get(Calendar.DAY_OF_MONTH));
            } catch (DatatypeConfigurationException e) {
                e.printStackTrace();
                return null;
            }
            CmAttributeDateMonthDay cmAttributeDateMonthDay = new CmAttributeDateMonthDay();
            cmAttributeDateMonthDay.setValue(xmlGregorianCalendar);

            return cmAttributeDateMonthDay;
        }
    }
    return null;
}

From source file:com.retroduction.carma.eventlisteners.ReportEventListener.java

public void destroy() {

    this.log.info("Finishing XML report");

    this.runProcessingEnd = System.currentTimeMillis();

    new StatisticalReportAnalyzer().enhanceReport(this.run);

    try {/*w  ww  .j  a  v  a2 s  . c o  m*/
        if (this.writeTimingInfo) {
            ProcessingInfo info = this.createTimingInformation(this.runProcessingStart, this.runProcessingEnd);
            this.run.setProcessingInfo(info);
        }
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    try {
        JAXBContext context = JAXBContext.newInstance(MutationRun.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(this.run, new FileOutputStream(new File(this.outputFile)));
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

}