Java Code Examples for javax.xml.datatype.XMLGregorianCalendar#getXMLSchemaType()

The following examples show how to use javax.xml.datatype.XMLGregorianCalendar#getXMLSchemaType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTimeLib.java    From jdmn with Apache License 2.0 6 votes vote down vote up
public XMLGregorianCalendar time(XMLGregorianCalendar from) {
    if (from == null) {
        return null;
    }

    FEELXMLGregorianCalendar calendar = (FEELXMLGregorianCalendar) from.clone();
    if (from.getXMLSchemaType() == DatatypeConstants.DATE) {
        calendar.setYear(DatatypeConstants.FIELD_UNDEFINED);
        calendar.setMonth(DatatypeConstants.FIELD_UNDEFINED);
        calendar.setDay(DatatypeConstants.FIELD_UNDEFINED);
        calendar.setHour(0);
        calendar.setMinute(0);
        calendar.setSecond(0);
        calendar.setZoneID("Z");
    } else if (from.getXMLSchemaType() == DatatypeConstants.DATETIME) {
        calendar.setYear(DatatypeConstants.FIELD_UNDEFINED);
        calendar.setMonth(DatatypeConstants.FIELD_UNDEFINED);
        calendar.setDay(DatatypeConstants.FIELD_UNDEFINED);
    }
    return this.isValidTime(calendar) ? calendar : null;
}
 
Example 2
Source File: RuntimeBuiltinLeafInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 3
Source File: RuntimeBuiltinLeafInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 4
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 5
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 6
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 7
Source File: RuntimeBuiltinLeafInfoImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 8
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}
 
Example 9
Source File: ParseDate.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected Value evaluate(ValueFactory valueFactory, Value arg1, Value arg2) throws ValueExprEvaluationException {
	if (!(arg1 instanceof Literal) || !(arg2 instanceof Literal)) {
		throw new ValueExprEvaluationException("Both arguments must be literals");
	}
	Literal value = (Literal) arg1;
	Literal format = (Literal) arg2;

	FieldAwareGregorianCalendar cal = new FieldAwareGregorianCalendar();

	SimpleDateFormat formatter = new SimpleDateFormat(format.getLabel());
	formatter.setCalendar(cal);
	try {
		formatter.parse(value.getLabel());
	} catch (ParseException e) {
		throw new ValueExprEvaluationException(e);
	}

	XMLGregorianCalendar xmlCal = datatypeFactory.newXMLGregorianCalendar(cal);
	if (!cal.isDateSet()) {
		xmlCal.setYear(DatatypeConstants.FIELD_UNDEFINED);
		xmlCal.setMonth(DatatypeConstants.FIELD_UNDEFINED);
		xmlCal.setDay(DatatypeConstants.FIELD_UNDEFINED);
	}
	if (!cal.isTimeSet()) {
		xmlCal.setHour(DatatypeConstants.FIELD_UNDEFINED);
		xmlCal.setMinute(DatatypeConstants.FIELD_UNDEFINED);
		xmlCal.setSecond(DatatypeConstants.FIELD_UNDEFINED);
	}
	if (!cal.isMillisecondSet()) {
		xmlCal.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
	}

	String dateValue = xmlCal.toXMLFormat();
	QName dateType = xmlCal.getXMLSchemaType();
	if (!cal.isTimezoneSet()) {
		int len = dateValue.length();
		if (dateValue.endsWith("Z")) {
			dateValue = dateValue.substring(0, len - 1);
		} else if (dateValue.charAt(len - 6) == '+' || dateValue.charAt(len - 6) == '-') {
			dateValue = dateValue.substring(0, len - 6);
		}
	}

	return valueFactory.createLiteral(dateValue, XMLDatatypeUtil.qnameToURI(dateType));
}
 
Example 10
Source File: RuntimeBuiltinLeafInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QName getTypeName(XMLGregorianCalendar cal) {
    return cal.getXMLSchemaType();
}