当前位置: 首页>>代码示例>>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;未经允许,请勿转载。