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 String
The raw dateTime string that was used to initialize this object.private String
day part of the dateTime object as Stringprivate String
fractional seconds part of the dateTime object as Stringprivate String
hour part of the dateTime object as Stringprivate String
hours part of the optional timezone as Stringprivate int
day part of the dateTime object as intprivate double
fractional seconds part of the dateTime object as intprivate int
hour part of the dateTime object as intprivate int
hours part of the optional timezone as intprivate int
minute part of the dateTime object as intprivate int
minutes part of the optional timezone as intprivate int
month part of the dateTime object as intprivate int
second part of the dateTime object as intprivate boolean
Flag indicating whether the timezone, if any, is positive or negative.private boolean
Flag indicating whether the year is positive or negative.private boolean
Flag indicating whether the values have been normalized.private int
year part of the dateTime object as intprivate String
minutes part of the dateTime object as Stringprivate String
minutes part of the optional timezone as Stringprivate String
month part of the dateTime object as Stringprivate String
seconds part of the dateTime object as Stringprivate String
year 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()
int
compareTo
(XMLDateTime otherDT) Compares this DateTime object to another DateTime object.private String
int2string
(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 boolean
is30DayMonth
(int month) Checks if the supplied month is a month with exactly 30 days.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 definitionboolean
Checks whether this object has already been normalized.void
Normalizes this dateTime object.private void
private void
toString()
Returns the xsd:dateTime string-representation of this object.private void
private void
verifyTokenValue
(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:
true
iff 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:
true
if 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
Returns the xsd:dateTime string-representation of this object. -
compareTo
Compares this DateTime object to another DateTime object.- Specified by:
compareTo
in interfaceComparable<XMLDateTime>
- Throws:
ClassCastException
- If other is not a DateTime object.
-
clone
-