Class XMLDateTime
- java.lang.Object
-
- org.eclipse.rdf4j.model.datatypes.XMLDateTime
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<XMLDateTime>
public class XMLDateTime extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable<XMLDateTime>
This class provides utility functions for comparisons operating onxml:dateTimedatatypes 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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdateTimeStringThe raw dateTime string that was used to initialize this object.private java.lang.Stringdaysday part of the dateTime object as Stringprivate java.lang.StringfractionalSecondsfractional seconds part of the dateTime object as Stringprivate java.lang.Stringhourshour part of the dateTime object as Stringprivate java.lang.StringhoursTimezonehours part of the optional timezone as Stringprivate intiDaysday part of the dateTime object as intprivate doubleiFractionalSecondsfractional seconds part of the dateTime object as intprivate intiHourshour part of the dateTime object as intprivate intiHoursTimezonehours part of the optional timezone as intprivate intiMinutesminute part of the dateTime object as intprivate intiMinutesTimezoneminutes part of the optional timezone as intprivate intiMonthsmonth part of the dateTime object as intprivate intiSecondssecond part of the dateTime object as intprivate booleanisNegativeTimezoneFlag indicating whether the timezone, if any, is positive or negative.private booleanisNegativeYearFlag indicating whether the year is positive or negative.private booleanisNormalizedFlag indicating whether the values have been normalized.private intiYearyear part of the dateTime object as intprivate java.lang.Stringminutesminutes part of the dateTime object as Stringprivate java.lang.StringminutesTimezoneminutes part of the optional timezone as Stringprivate java.lang.Stringmonthsmonth part of the dateTime object as Stringprivate java.lang.Stringsecondsseconds part of the dateTime object as Stringprivate java.lang.Stringyearyear part of the dateTime object as String
-
Constructor Summary
Constructors Constructor Description XMLDateTime(java.lang.String dateTimeString)Creates a new XMLDateTime object for the supplied xsd:dateTime string value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()intcompareTo(XMLDateTime otherDT)Compares this DateTime object to another DateTime object.private java.lang.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 definitionbooleanisNormalized()Checks whether this object has already been normalized.voidnormalize()Normalizes this dateTime object.private voidparseDateTimeString()private voidsetNumericFields()java.lang.StringtoString()Returns the xsd:dateTime string-representation of this object.private voidvalidateFieldValues()private voidverifyTokenValue(java.lang.String token, java.lang.String expected, java.lang.String errMsg)
-
-
-
Field Detail
-
dateTimeString
private final java.lang.String dateTimeString
The raw dateTime string that was used to initialize this object.
-
isNegativeYear
private boolean isNegativeYear
Flag indicating whether the year is positive or negative.
-
year
private java.lang.String year
year part of the dateTime object as String
-
months
private java.lang.String months
month part of the dateTime object as String
-
days
private java.lang.String days
day part of the dateTime object as String
-
hours
private java.lang.String hours
hour part of the dateTime object as String
-
minutes
private java.lang.String minutes
minutes part of the dateTime object as String
-
seconds
private java.lang.String seconds
seconds part of the dateTime object as String
-
fractionalSeconds
private java.lang.String fractionalSeconds
fractional seconds part of the dateTime object as String
-
isNegativeTimezone
private boolean isNegativeTimezone
Flag indicating whether the timezone, if any, is positive or negative.
-
hoursTimezone
private java.lang.String hoursTimezone
hours part of the optional timezone as String
-
minutesTimezone
private java.lang.String minutesTimezone
minutes part of the optional timezone as String
-
iYear
private int iYear
year part of the dateTime object as int
-
iMonths
private int iMonths
month part of the dateTime object as int
-
iDays
private int iDays
day part of the dateTime object as int
-
iHours
private int iHours
hour part of the dateTime object as int
-
iMinutes
private int iMinutes
minute part of the dateTime object as int
-
iSeconds
private int iSeconds
second part of the dateTime object as int
-
iFractionalSeconds
private double iFractionalSeconds
fractional seconds part of the dateTime object as int
-
iHoursTimezone
private int iHoursTimezone
hours part of the optional timezone as int
-
iMinutesTimezone
private int iMinutesTimezone
minutes part of the optional timezone as int
-
isNormalized
private boolean isNormalized
Flag indicating whether the values have been normalized.
-
-
Constructor Detail
-
XMLDateTime
public XMLDateTime(java.lang.String dateTimeString)
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:
java.lang.IllegalArgumentException- if the supplied lexical value does not constitute a valid xsd:dateTime.
-
-
Method Detail
-
parseDateTimeString
private void parseDateTimeString()
-
verifyTokenValue
private void verifyTokenValue(java.lang.String token, java.lang.String expected, java.lang.String errMsg)
-
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
private java.lang.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.
-
toString
public java.lang.String toString()
Returns the xsd:dateTime string-representation of this object.- Overrides:
toStringin classjava.lang.Object- Returns:
- An xsd:dateTime value, e.g. 1999-05-31T13:20:00-05:00.
-
compareTo
public int compareTo(XMLDateTime otherDT)
Compares this DateTime object to another DateTime object.- Specified by:
compareToin interfacejava.lang.Comparable<XMLDateTime>- Throws:
java.lang.ClassCastException- If other is not a DateTime object.
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
-