Class GDateValue

    • Field Detail

      • year

        protected int year
      • month

        protected byte month
      • day

        protected byte day
      • hasNoYearZero

        protected boolean hasNoYearZero
      • daysPerMonth

        protected static byte[] daysPerMonth
        Test whether a candidate date is actually a valid date in the proleptic Gregorian calendar
      • monthData

        protected static final short[] monthData
    • Constructor Detail

      • GDateValue

        public GDateValue()
    • Method Detail

      • getYear

        public int getYear()
        Get the year component of the date (in local form)
        Returns:
        the year component, as represented internally (allowing a year zero)
      • getMonth

        public byte getMonth()
        Get the month component of the date (in local form)
        Returns:
        the month component (1-12)
      • getDay

        public byte getDay()
        Get the day component of the date (in local form)
        Returns:
        the day component (1-31)
      • getCalendar

        public java.util.GregorianCalendar getCalendar()
        Description copied from class: CalendarValue
        Get a Java Calendar object that represents this date/time value. The Calendar object will be newly created for the purpose. This will respect the timezone if there is one (provided the timezone is within the range supported by the GregorianCalendar class, which in practice means that it is not -14:00). If there is no timezone or if the timezone is out of range, the result will be in GMT.
        Specified by:
        getCalendar in class CalendarValue
        Returns:
        A Calendar object representing the date and time. Note that Java can only represent the time to millisecond precision.
      • setLexicalValue

        protected static ConversionResult setLexicalValue​(GDateValue d,
                                                          java.lang.CharSequence s,
                                                          boolean allowYearZero)
        Initialize the DateValue using a character string in the format yyyy-mm-dd and an optional time zone. Input must have format [-]yyyy-mm-dd[([+|-]hh:mm | Z)]
        Parameters:
        d - the "raw" DateValue to be populated
        s - the supplied string value
        allowYearZero - true if (as in XSD 1.1) there is a year zero, false if (as in XSD 1.0) there is not
        Returns:
        either the supplied GDateValue, with its data initialized; or a ValidationFailure
      • isValidDate

        public static boolean isValidDate​(int year,
                                          int month,
                                          int day)
        Determine whether a given date is valid
        Parameters:
        year - the year (permitting year zero)
        month - the month (1-12)
        day - the day (1-31)
        Returns:
        true if this is a valid date
      • isLeapYear

        public static boolean isLeapYear​(int year)
        Test whether a year is a leap year
        Parameters:
        year - the year (permitting year zero)
        Returns:
        true if the supplied year is a leap year
      • equals

        public boolean equals​(java.lang.Object o)
        The equals() methods on atomic values is defined to follow the semantics of eq when applied to two atomic values. When the other operand is not an atomic value, the result is undefined (may be false, may be an exception). When the other operand is an atomic value that cannot be compared with this one, the method returns false.

        The hashCode() method is consistent with equals().

        This implementation performs a context-free comparison: it fails with ClassCastException if one value has a timezone and the other does not.

        Specified by:
        equals in class AtomicValue
        Parameters:
        o - the other value
        Returns:
        true if the other operand is an atomic value and the two values are equal as defined by the XPath eq operator
        Throws:
        java.lang.ClassCastException - if the values are not comparable
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(CalendarValue other,
                             int implicitTimezone)
                      throws NoDynamicContextException
        Compare this value to another value of the same type, using the supplied context object to get the implicit timezone if required. This method implements the XPath comparison semantics.
        Specified by:
        compareTo in class CalendarValue
        Parameters:
        other - the value to be compared
        implicitTimezone - the implicit timezone to be used for a value with no timezone
        Returns:
        -1 if this value is less, 0 if equal, +1 if greater
        Throws:
        NoDynamicContextException - if the result depends on the implicit timezone and the supplied timezone is CalendarValue.MISSING_TIMEZONE
      • toDateTime

        public DateTimeValue toDateTime()
        Convert to DateTime.
        Specified by:
        toDateTime in class CalendarValue
        Returns:
        the starting instant of the GDateValue (with the same timezone)
      • getSchemaComparable

        public java.lang.Comparable getSchemaComparable()
        Description copied from class: AtomicValue
        Get a Comparable value that implements the XML Schema ordering comparison semantics for this value. An implementation must be provided for all atomic types.

        In the case of data types that are partially ordered, the returned Comparable extends the standard semantics of the compareTo() method by returning the value SequenceTool.INDETERMINATE_ORDERING when there is no defined order relationship between two given values. This value is also returned when two values of different types are compared.

        Specified by:
        getSchemaComparable in interface AtomicSequence
        Specified by:
        getSchemaComparable in class AtomicValue
        Returns:
        a Comparable that follows XML Schema comparison rules
      • getComponent

        public AtomicValue getComponent​(AccessorFn.Component component)
                                 throws XPathException
        Get a component of the value. Returns null if the timezone component is requested and is not present.
        Overrides:
        getComponent in class AtomicValue
        Parameters:
        component - the required component
        Returns:
        the value of the requested component of this value
        Throws:
        XPathException - if a dynamic error occurs