Java Code Examples for com.sun.org.apache.xerces.internal.impl.Constants#SCHEMA_1_1_SUPPORT

The following examples show how to use com.sun.org.apache.xerces.internal.impl.Constants#SCHEMA_1_1_SUPPORT . 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: XSSimpleTypeDecl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 2
Source File: XSSimpleTypeDecl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 3
Source File: XSSimpleTypeDecl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private short getPrimitiveDV(short validationDV){

        if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
            return DV_STRING;
        }
        else if (validationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return validationDV;
        }

    }
 
Example 4
Source File: XSSimpleTypeDecl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 5
Source File: XSSimpleTypeDecl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 6
Source File: XSSimpleTypeDecl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 7
Source File: XSSimpleTypeDecl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private short getPrimitiveDV(short validationDV){

        if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
            return DV_STRING;
        }
        else if (validationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return validationDV;
        }

    }
 
Example 8
Source File: XSSimpleTypeDecl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 9
Source File: XSSimpleTypeDecl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private short getPrimitiveDV(short validationDV){

        if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
            return DV_STRING;
        }
        else if (validationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return validationDV;
        }

    }
 
Example 10
Source File: XSSimpleTypeDecl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public short getPrimitiveKind() {
    if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) {
        if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) {
            return DV_STRING;
        }
        else if (fValidationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return fValidationDV;
        }
    }
    else {
        // REVISIT: error situation. runtime exception?
        return (short)0;
    }
}
 
Example 11
Source File: XSSimpleTypeDecl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private short getPrimitiveDV(short validationDV){

        if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
            return DV_STRING;
        }
        else if (validationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return validationDV;
        }

    }
 
Example 12
Source File: AbstractDateTimeDV.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * If timezone present - normalize dateTime [E Adding durations to
 * dateTimes]
 *
 * @param date CCYY-MM-DDThh:mm:ss+03
 */
protected void normalize(DateTimeData date) {

    // REVISIT: we have common code in addDuration() for durations
    //          should consider reorganizing it.
    //

    //add minutes (from time zone)
    int negate = -1;

    if (DEBUG) {
        System.out.println("==>date.minute" + date.minute);
        System.out.println("==>date.timezoneMin" + date.timezoneMin);
    }
    int temp = date.minute + negate * date.timezoneMin;
    int carry = fQuotient(temp, 60);
    date.minute = mod(temp, 60, carry);

    if (DEBUG) {
        System.out.println("==>carry: " + carry);
    }
    //add hours
    temp = date.hour + negate * date.timezoneHr + carry;
    carry = fQuotient(temp, 24);
    date.hour = mod(temp, 24, carry);
    if (DEBUG) {
        System.out.println("==>date.hour" + date.hour);
        System.out.println("==>carry: " + carry);
    }

    date.day = date.day + carry;

    while (true) {
        temp = maxDayInMonthFor(date.year, date.month);
        if (date.day < 1) {
            date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
            carry = -1;
        } else if (date.day > temp) {
            date.day = date.day - temp;
            carry = 1;
        } else {
            break;
        }
        temp = date.month + carry;
        date.month = modulo(temp, 1, 13);
        date.year = date.year + fQuotient(temp, 1, 13);
        if (date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
            date.year = (date.timezoneHr < 0 || date.timezoneMin < 0) ? 1 : -1;
        }
    }
    date.utc = 'Z';
}
 
Example 13
Source File: AbstractDateTimeDV.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601
 * Conventions]
 *
 * @param data
 */
protected void validateDateTime(DateTimeData data) {

    //REVISIT: should we throw an exception for not valid dates
    //          or reporting an error message should be sufficient?

    /**
     * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
     */
    if (!Constants.SCHEMA_1_1_SUPPORT && data.year == 0) {
        throw new RuntimeException("The year \"0000\" is an illegal year value");

    }

    if (data.month < 1 || data.month > 12) {
        throw new RuntimeException("The month must have values 1 to 12");

    }

    //validate days
    if (data.day > maxDayInMonthFor(data.year, data.month) || data.day < 1) {
        throw new RuntimeException("The day must have values 1 to 31");
    }

    //validate hours
    if (data.hour > 23 || data.hour < 0) {
        if (data.hour == 24 && data.minute == 0 && data.second == 0) {
            data.hour = 0;
            if (++data.day > maxDayInMonthFor(data.year, data.month)) {
                data.day = 1;
                if (++data.month > 12) {
                    data.month = 1;
                    if (Constants.SCHEMA_1_1_SUPPORT) {
                        ++data.year;
                    } else if (++data.year == 0) {
                        data.year = 1;
                    }
                }
            }
        } else {
            throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
        }
    }

    //validate
    if (data.minute > 59 || data.minute < 0) {
        throw new RuntimeException("Minute must have values 0-59");
    }

    //validate
    if (data.second >= 60 || data.second < 0) {
        throw new RuntimeException("Second must have values 0-59");

    }

    //validate
    if (data.timezoneHr > 14 || data.timezoneHr < -14) {
        throw new RuntimeException("Time zone should have range -14:00 to +14:00");
    } else {
        if ((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0) {
            throw new RuntimeException("Time zone should have range -14:00 to +14:00");
        } else if (data.timezoneMin > 59 || data.timezoneMin < -59) {
            throw new RuntimeException("Minute must have values 0-59");
        }
    }

}
 
Example 14
Source File: AbstractDateTimeDV.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601
 * Conventions]
 *
 * @param data
 */
protected void validateDateTime(DateTimeData data) {

    //REVISIT: should we throw an exception for not valid dates
    //          or reporting an error message should be sufficient?

    /**
     * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
     */
    if (!Constants.SCHEMA_1_1_SUPPORT && data.year == 0) {
        throw new RuntimeException("The year \"0000\" is an illegal year value");

    }

    if (data.month < 1 || data.month > 12) {
        throw new RuntimeException("The month must have values 1 to 12");

    }

    //validate days
    if (data.day > maxDayInMonthFor(data.year, data.month) || data.day < 1) {
        throw new RuntimeException("The day must have values 1 to 31");
    }

    //validate hours
    if (data.hour > 23 || data.hour < 0) {
        if (data.hour == 24 && data.minute == 0 && data.second == 0) {
            data.hour = 0;
            if (++data.day > maxDayInMonthFor(data.year, data.month)) {
                data.day = 1;
                if (++data.month > 12) {
                    data.month = 1;
                    if (Constants.SCHEMA_1_1_SUPPORT) {
                        ++data.year;
                    } else if (++data.year == 0) {
                        data.year = 1;
                    }
                }
            }
        } else {
            throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
        }
    }

    //validate
    if (data.minute > 59 || data.minute < 0) {
        throw new RuntimeException("Minute must have values 0-59");
    }

    //validate
    if (data.second >= 60 || data.second < 0) {
        throw new RuntimeException("Second must have values 0-59");

    }

    //validate
    if (data.timezoneHr > 14 || data.timezoneHr < -14) {
        throw new RuntimeException("Time zone should have range -14:00 to +14:00");
    } else {
        if ((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0) {
            throw new RuntimeException("Time zone should have range -14:00 to +14:00");
        } else if (data.timezoneMin > 59 || data.timezoneMin < -59) {
            throw new RuntimeException("Minute must have values 0-59");
        }
    }

}
 
Example 15
Source File: AbstractDateTimeDV.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601
 * Conventions]
 *
 * @param data
 */
protected void validateDateTime(DateTimeData data) {

    //REVISIT: should we throw an exception for not valid dates
    //          or reporting an error message should be sufficient?

    /**
     * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
     */
    if (!Constants.SCHEMA_1_1_SUPPORT && data.year == 0) {
        throw new RuntimeException("The year \"0000\" is an illegal year value");

    }

    if (data.month < 1 || data.month > 12) {
        throw new RuntimeException("The month must have values 1 to 12");

    }

    //validate days
    if (data.day > maxDayInMonthFor(data.year, data.month) || data.day < 1) {
        throw new RuntimeException("The day must have values 1 to 31");
    }

    //validate hours
    if (data.hour > 23 || data.hour < 0) {
        if (data.hour == 24 && data.minute == 0 && data.second == 0) {
            data.hour = 0;
            if (++data.day > maxDayInMonthFor(data.year, data.month)) {
                data.day = 1;
                if (++data.month > 12) {
                    data.month = 1;
                    if (Constants.SCHEMA_1_1_SUPPORT) {
                        ++data.year;
                    } else if (++data.year == 0) {
                        data.year = 1;
                    }
                }
            }
        } else {
            throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
        }
    }

    //validate
    if (data.minute > 59 || data.minute < 0) {
        throw new RuntimeException("Minute must have values 0-59");
    }

    //validate
    if (data.second >= 60 || data.second < 0) {
        throw new RuntimeException("Second must have values 0-59");

    }

    //validate
    if (data.timezoneHr > 14 || data.timezoneHr < -14) {
        throw new RuntimeException("Time zone should have range -14:00 to +14:00");
    } else {
        if ((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0) {
            throw new RuntimeException("Time zone should have range -14:00 to +14:00");
        } else if (data.timezoneMin > 59 || data.timezoneMin < -59) {
            throw new RuntimeException("Minute must have values 0-59");
        }
    }

}
 
Example 16
Source File: AbstractDateTimeDV.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * If timezone present - normalize dateTime [E Adding durations to
 * dateTimes]
 *
 * @param date CCYY-MM-DDThh:mm:ss+03
 */
protected void normalize(DateTimeData date) {

    // REVISIT: we have common code in addDuration() for durations
    //          should consider reorganizing it.
    //

    //add minutes (from time zone)
    int negate = -1;

    if (DEBUG) {
        System.out.println("==>date.minute" + date.minute);
        System.out.println("==>date.timezoneMin" + date.timezoneMin);
    }
    int temp = date.minute + negate * date.timezoneMin;
    int carry = fQuotient(temp, 60);
    date.minute = mod(temp, 60, carry);

    if (DEBUG) {
        System.out.println("==>carry: " + carry);
    }
    //add hours
    temp = date.hour + negate * date.timezoneHr + carry;
    carry = fQuotient(temp, 24);
    date.hour = mod(temp, 24, carry);
    if (DEBUG) {
        System.out.println("==>date.hour" + date.hour);
        System.out.println("==>carry: " + carry);
    }

    date.day = date.day + carry;

    while (true) {
        temp = maxDayInMonthFor(date.year, date.month);
        if (date.day < 1) {
            date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
            carry = -1;
        } else if (date.day > temp) {
            date.day = date.day - temp;
            carry = 1;
        } else {
            break;
        }
        temp = date.month + carry;
        date.month = modulo(temp, 1, 13);
        date.year = date.year + fQuotient(temp, 1, 13);
        if (date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
            date.year = (date.timezoneHr < 0 || date.timezoneMin < 0) ? 1 : -1;
        }
    }
    date.utc = 'Z';
}
 
Example 17
Source File: AbstractDateTimeDV.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * If timezone present - normalize dateTime [E Adding durations to
 * dateTimes]
 *
 * @param date CCYY-MM-DDThh:mm:ss+03
 */
protected void normalize(DateTimeData date) {

    // REVISIT: we have common code in addDuration() for durations
    //          should consider reorganizing it.
    //

    //add minutes (from time zone)
    int negate = -1;

    if (DEBUG) {
        System.out.println("==>date.minute" + date.minute);
        System.out.println("==>date.timezoneMin" + date.timezoneMin);
    }
    int temp = date.minute + negate * date.timezoneMin;
    int carry = fQuotient(temp, 60);
    date.minute = mod(temp, 60, carry);

    if (DEBUG) {
        System.out.println("==>carry: " + carry);
    }
    //add hours
    temp = date.hour + negate * date.timezoneHr + carry;
    carry = fQuotient(temp, 24);
    date.hour = mod(temp, 24, carry);
    if (DEBUG) {
        System.out.println("==>date.hour" + date.hour);
        System.out.println("==>carry: " + carry);
    }

    date.day = date.day + carry;

    while (true) {
        temp = maxDayInMonthFor(date.year, date.month);
        if (date.day < 1) {
            date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
            carry = -1;
        } else if (date.day > temp) {
            date.day = date.day - temp;
            carry = 1;
        } else {
            break;
        }
        temp = date.month + carry;
        date.month = modulo(temp, 1, 13);
        date.year = date.year + fQuotient(temp, 1, 13);
        if (date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
            date.year = (date.timezoneHr < 0 || date.timezoneMin < 0) ? 1 : -1;
        }
    }
    date.utc = 'Z';
}
 
Example 18
Source File: AbstractDateTimeDV.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601
 * Conventions]
 *
 * @param data
 */
protected void validateDateTime(DateTimeData data) {

    //REVISIT: should we throw an exception for not valid dates
    //          or reporting an error message should be sufficient?

    /**
     * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
     */
    if (!Constants.SCHEMA_1_1_SUPPORT && data.year == 0) {
        throw new RuntimeException("The year \"0000\" is an illegal year value");

    }

    if (data.month < 1 || data.month > 12) {
        throw new RuntimeException("The month must have values 1 to 12");

    }

    //validate days
    if (data.day > maxDayInMonthFor(data.year, data.month) || data.day < 1) {
        throw new RuntimeException("The day must have values 1 to 31");
    }

    //validate hours
    if (data.hour > 23 || data.hour < 0) {
        if (data.hour == 24 && data.minute == 0 && data.second == 0) {
            data.hour = 0;
            if (++data.day > maxDayInMonthFor(data.year, data.month)) {
                data.day = 1;
                if (++data.month > 12) {
                    data.month = 1;
                    if (Constants.SCHEMA_1_1_SUPPORT) {
                        ++data.year;
                    } else if (++data.year == 0) {
                        data.year = 1;
                    }
                }
            }
        } else {
            throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
        }
    }

    //validate
    if (data.minute > 59 || data.minute < 0) {
        throw new RuntimeException("Minute must have values 0-59");
    }

    //validate
    if (data.second >= 60 || data.second < 0) {
        throw new RuntimeException("Second must have values 0-59");

    }

    //validate
    if (data.timezoneHr > 14 || data.timezoneHr < -14) {
        throw new RuntimeException("Time zone should have range -14:00 to +14:00");
    } else {
        if ((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0) {
            throw new RuntimeException("Time zone should have range -14:00 to +14:00");
        } else if (data.timezoneMin > 59 || data.timezoneMin < -59) {
            throw new RuntimeException("Minute must have values 0-59");
        }
    }

}
 
Example 19
Source File: AbstractDateTimeDV.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * If timezone present - normalize dateTime [E Adding durations to
 * dateTimes]
 *
 * @param date CCYY-MM-DDThh:mm:ss+03
 */
protected void normalize(DateTimeData date) {

    // REVISIT: we have common code in addDuration() for durations
    //          should consider reorganizing it.
    //

    //add minutes (from time zone)
    int negate = -1;

    if (DEBUG) {
        System.out.println("==>date.minute" + date.minute);
        System.out.println("==>date.timezoneMin" + date.timezoneMin);
    }
    int temp = date.minute + negate * date.timezoneMin;
    int carry = fQuotient(temp, 60);
    date.minute = mod(temp, 60, carry);

    if (DEBUG) {
        System.out.println("==>carry: " + carry);
    }
    //add hours
    temp = date.hour + negate * date.timezoneHr + carry;
    carry = fQuotient(temp, 24);
    date.hour = mod(temp, 24, carry);
    if (DEBUG) {
        System.out.println("==>date.hour" + date.hour);
        System.out.println("==>carry: " + carry);
    }

    date.day = date.day + carry;

    while (true) {
        temp = maxDayInMonthFor(date.year, date.month);
        if (date.day < 1) {
            date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
            carry = -1;
        } else if (date.day > temp) {
            date.day = date.day - temp;
            carry = 1;
        } else {
            break;
        }
        temp = date.month + carry;
        date.month = modulo(temp, 1, 13);
        date.year = date.year + fQuotient(temp, 1, 13);
        if (date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
            date.year = (date.timezoneHr < 0 || date.timezoneMin < 0) ? 1 : -1;
        }
    }
    date.utc = 'Z';
}
 
Example 20
Source File: AbstractDateTimeDV.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * If timezone present - normalize dateTime [E Adding durations to
 * dateTimes]
 *
 * @param date CCYY-MM-DDThh:mm:ss+03
 */
protected void normalize(DateTimeData date) {

    // REVISIT: we have common code in addDuration() for durations
    //          should consider reorganizing it.
    //

    //add minutes (from time zone)
    int negate = -1;

    if (DEBUG) {
        System.out.println("==>date.minute" + date.minute);
        System.out.println("==>date.timezoneMin" + date.timezoneMin);
    }
    int temp = date.minute + negate * date.timezoneMin;
    int carry = fQuotient(temp, 60);
    date.minute = mod(temp, 60, carry);

    if (DEBUG) {
        System.out.println("==>carry: " + carry);
    }
    //add hours
    temp = date.hour + negate * date.timezoneHr + carry;
    carry = fQuotient(temp, 24);
    date.hour = mod(temp, 24, carry);
    if (DEBUG) {
        System.out.println("==>date.hour" + date.hour);
        System.out.println("==>carry: " + carry);
    }

    date.day = date.day + carry;

    while (true) {
        temp = maxDayInMonthFor(date.year, date.month);
        if (date.day < 1) {
            date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
            carry = -1;
        } else if (date.day > temp) {
            date.day = date.day - temp;
            carry = 1;
        } else {
            break;
        }
        temp = date.month + carry;
        date.month = modulo(temp, 1, 13);
        date.year = date.year + fQuotient(temp, 1, 13);
        if (date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
            date.year = (date.timezoneHr < 0 || date.timezoneMin < 0) ? 1 : -1;
        }
    }
    date.utc = 'Z';
}