Class XMLDateTime
java.lang.Object
org.eclipse.rdf4j.model.datatypes.XMLDateTime
- All Implemented Interfaces:
Cloneable, Comparable<XMLDateTime>
This class provides utility functions for comparisons operating on
xml:dateTime datatypes as specified
in W3C XML Schema Definition Language (XSD) 1.1 Part 2:
Datatypes.
Known deviations from the standard: - the range of years in this implementation is limited to Integer.MIN_VALUE to
Integer.MAX_VALUE for practical reasons.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe raw dateTime string that was used to initialize this object.private Stringday part of the dateTime object as Stringprivate Stringfractional seconds part of the dateTime object as Stringprivate Stringhour part of the dateTime object as Stringprivate Stringhours part of the optional timezone as Stringprivate intday part of the dateTime object as intprivate doublefractional seconds part of the dateTime object as intprivate inthour part of the dateTime object as intprivate inthours part of the optional timezone as intprivate intminute part of the dateTime object as intprivate intminutes part of the optional timezone as intprivate intmonth part of the dateTime object as intprivate intsecond part of the dateTime object as intprivate booleanFlag indicating whether the timezone, if any, is positive or negative.private booleanFlag indicating whether the year is positive or negative.private booleanFlag indicating whether the values have been normalized.private intyear part of the dateTime object as intprivate Stringminutes part of the dateTime object as Stringprivate Stringminutes part of the optional timezone as Stringprivate Stringmonth part of the dateTime object as Stringprivate Stringseconds part of the dateTime object as Stringprivate Stringyear part of the dateTime object as String -
Constructor Summary
ConstructorsConstructorDescriptionXMLDateTime(String dateTimeString) Creates a new XMLDateTime object for the supplied xsd:dateTime string value. -
Method Summary
Modifier and TypeMethodDescriptionclone()intcompareTo(XMLDateTime otherDT) Compares this DateTime object to another DateTime object.private Stringint2string(int iValue, int minDigits) Converts an integer to a string, enforcing the resulting string to have at least minDigits digits by prepending zeros if it has less than that amount of digits.private booleanis30DayMonth(int month) Checks if the supplied month is a month with exactly 30 days.private booleanisLeapYear(int year) Checks if the supplied year is a leap year (one in which February 29 occurs) according to the definition in the XML Schema XSD definitionbooleanChecks whether this object has already been normalized.voidNormalizes this dateTime object.private voidprivate voidtoString()Returns the xsd:dateTime string-representation of this object.private voidprivate voidverifyTokenValue(String token, String expected, String errMsg)
-
Field Details
-
dateTimeString
The raw dateTime string that was used to initialize this object. -
isNegativeYear
private boolean isNegativeYearFlag indicating whether the year is positive or negative. -
year
year part of the dateTime object as String -
months
month part of the dateTime object as String -
days
day part of the dateTime object as String -
hours
hour part of the dateTime object as String -
minutes
minutes part of the dateTime object as String -
seconds
seconds part of the dateTime object as String -
fractionalSeconds
fractional seconds part of the dateTime object as String -
isNegativeTimezone
private boolean isNegativeTimezoneFlag indicating whether the timezone, if any, is positive or negative. -
hoursTimezone
hours part of the optional timezone as String -
minutesTimezone
minutes part of the optional timezone as String -
iYear
private int iYearyear part of the dateTime object as int -
iMonths
private int iMonthsmonth part of the dateTime object as int -
iDays
private int iDaysday part of the dateTime object as int -
iHours
private int iHourshour part of the dateTime object as int -
iMinutes
private int iMinutesminute part of the dateTime object as int -
iSeconds
private int iSecondssecond part of the dateTime object as int -
iFractionalSeconds
private double iFractionalSecondsfractional seconds part of the dateTime object as int -
iHoursTimezone
private int iHoursTimezonehours part of the optional timezone as int -
iMinutesTimezone
private int iMinutesTimezoneminutes part of the optional timezone as int -
isNormalized
private boolean isNormalizedFlag indicating whether the values have been normalized.
-
-
Constructor Details
-
XMLDateTime
Creates a new XMLDateTime object for the supplied xsd:dateTime string value.- Parameters:
dateTimeString- An xsd:dateTime lexical value, for example 1999-05-31T13:20:00-05:00.- Throws:
IllegalArgumentException- if the supplied lexical value does not constitute a valid xsd:dateTime.
-
-
Method Details
-
parseDateTimeString
private void parseDateTimeString() -
verifyTokenValue
-
setNumericFields
private void setNumericFields() -
validateFieldValues
private void validateFieldValues() -
is30DayMonth
private boolean is30DayMonth(int month) Checks if the supplied month is a month with exactly 30 days.- Parameters:
month- the month- Returns:
trueiff the supplied month has exactly 30 days.
-
isLeapYear
private boolean isLeapYear(int year) Checks if the supplied year is a leap year (one in which February 29 occurs) according to the definition in the XML Schema XSD definition- Parameters:
year- the year.- Returns:
trueif the supplied year is a leap year according to the XSD definition.
-
isNormalized
public boolean isNormalized()Checks whether this object has already been normalized. -
normalize
public void normalize()Normalizes this dateTime object. -
int2string
Converts an integer to a string, enforcing the resulting string to have at least minDigits digits by prepending zeros if it has less than that amount of digits. -
toString
-
compareTo
Compares this DateTime object to another DateTime object.- Specified by:
compareToin interfaceComparable<XMLDateTime>- Throws:
ClassCastException- If other is not a DateTime object.
-
clone
-