當前位置: 首頁>>代碼示例>>Java>>正文


Java DatatypeConstants.FEBRUARY屬性代碼示例

本文整理匯總了Java中javax.xml.datatype.DatatypeConstants.FEBRUARY屬性的典型用法代碼示例。如果您正苦於以下問題:Java DatatypeConstants.FEBRUARY屬性的具體用法?Java DatatypeConstants.FEBRUARY怎麽用?Java DatatypeConstants.FEBRUARY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.xml.datatype.DatatypeConstants的用法示例。


在下文中一共展示了DatatypeConstants.FEBRUARY屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: maximumDayInMonthFor

private static int maximumDayInMonthFor(BigInteger year, int month) {
    if (month != DatatypeConstants.FEBRUARY) {
        return daysInMonth[month];
    } else {
        if (year.mod(FOUR_HUNDRED).equals(BigInteger.ZERO) ||
                (!year.mod(HUNDRED).equals(BigInteger.ZERO) &&
                        year.mod(FOUR).equals(BigInteger.ZERO))) {
            // is a leap year.
            return 29;
        } else {
            return daysInMonth[month];
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:XMLGregorianCalendarImpl.java

示例2: maximumDayInMonthFor

private static int maximumDayInMonthFor(BigInteger year, int month) {
    if (month != DatatypeConstants.FEBRUARY) {
        return DaysInMonth.table[month];
    } else {
        if (year.mod(FOUR_HUNDRED).equals(BigInteger.ZERO) ||
                (!year.mod(HUNDRED).equals(BigInteger.ZERO) &&
                        year.mod(FOUR).equals(BigInteger.ZERO))) {
            // is a leap year.
            return 29;
        } else {
            return DaysInMonth.table[month];
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:XMLGregorianCalendarImpl.java

示例3: isValid

/**
 * Validate instance by <code>getXMLSchemaType()</code> constraints.
 * @return true if data values are valid.
 */
public boolean isValid() {
    // since setters do not allow for invalid values,
    // (except for exceptional case of year field of zero),
    // no need to check for anything except for constraints
    // between fields.

    //check if days in month is valid. Can be dependent on leap year.
    if (getMonth() == DatatypeConstants.FEBRUARY) {
        // years could not be set
        int maxDays = 29;

        if (eon == null) {
            if(year!=DatatypeConstants.FIELD_UNDEFINED)
                maxDays = maximumDayInMonthFor(year,getMonth());
        } else {
            BigInteger years = getEonAndYear();
            if (years != null) {
                maxDays = maximumDayInMonthFor(getEonAndYear(), DatatypeConstants.FEBRUARY);
            }
        }
        if (getDay() > maxDays) {
            return false;
        }
    }

    // http://www.w3.org/2001/05/xmlschema-errata#e2-45
    if (getHour() == 24) {
        if(getMinute() != 0) {
            return false;
        } else if (getSecond() != 0) {
            return false;
        }
    }

    // XML Schema 1.0 specification defines year value of zero as
    // invalid. Allow this class to set year field to zero
    // since XML Schema 1.0 errata states that lexical zero will
    // be allowed in next version and treated as 1 B.C.E.
    if (eon == null) {
        // optimize check.
        if (year == 0) {
            return false;
        }
    } else {
        BigInteger yearField = getEonAndYear();
        if (yearField != null) {
            int result = compareField(yearField, BigInteger.ZERO);
            if (result == DatatypeConstants.EQUAL) {
                return false;
            }
        }
    }
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:58,代碼來源:XMLGregorianCalendarImpl.java


注:本文中的javax.xml.datatype.DatatypeConstants.FEBRUARY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。