Class GDuration

    • Constructor Detail

      • GDuration

        public GDuration()
        Constructs an empty GDuration representing zero seconds.
      • GDuration

        public GDuration​(CharSequence str)
        Constructs a GDuration from a lexical representation. The lexical space contains the union of the lexical spaces of all the schema date/time types (except for duration).
      • GDuration

        public GDuration​(int sign,
                         int year,
                         int month,
                         int day,
                         int hour,
                         int minute,
                         int second,
                         BigDecimal fraction)
        Constructs a GDuration with the specified sign, year, month, day, hours, minutes, seconds, and optional fractional seconds.
        sign - +1 for a positive duration, -1 for a negative duration
        IllegalArgumentException - if the sign is not 1 or -1
      • GDuration

        public GDuration​(GDurationSpecification gDuration)
        Constructs a GDuration from another GDurationSpecification.
    • Method Detail

      • clone

        public Object clone()
        Builds another GDate with the same value as this one.
      • getSign

        public final int getSign()
        Returns the sign of the duration: +1 is forwards and -1 is backwards in time.
        Specified by:
        getSign in interface GDurationSpecification
      • isValid

        public boolean isValid()
        Returns true if all of the individual components of the duration are nonnegative.
        Specified by:
        isValid in interface GDurationSpecification
      • compareToGDuration

        public final int compareToGDuration​(GDurationSpecification duration)
        Comparison to another GDuration.
        • Returns -1 if this < duration. (less-than)
        • Returns 0 if this == duration. (equal)
        • Returns 1 if this > duration. (greater-than)
        • Returns 2 if this <> duration. (incomparable)
        Two instances are incomparable if they have different amounts of information.
        Specified by:
        compareToGDuration in interface GDurationSpecification
      • toString

        public String toString()
        The natural string representation of the duration.

        Any components that are zero are omitted. Note that if the duration is invalid, i.e., it has negative components, those negative components are serialized out here. To check for validity, use the isValid() method; and to normalize most durations to a valid form use the normalize() method.

        toString in class Object
      • add

        public GDuration add​(GDurationSpecification duration)
        Returns a new GDuration which is the sum of this one and the supplied duration. Does a fieldwise addition, with no normalization.
      • subtract

        public GDuration subtract​(GDurationSpecification duration)
        Returns a new GDuration which is the result of subtracting the supplied duration from this one. Does a fieldwise subtraction, with no normalization.
      • equals

        public boolean equals​(Object obj)
        Two GDurations are equal if all their fields are equal. The equals function does not apply normalizatin.
        equals in class Object
      • hashCode

        public int hashCode()
        hashCode in class Object