Class XMLDateTime

java.lang.Object
org.eclipse.rdf4j.model.datatypes.XMLDateTime
All Implemented Interfaces:
Cloneable, Comparable<XMLDateTime>

public class XMLDateTime extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The raw dateTime string that was used to initialize this object.
    private String
    day part of the dateTime object as String
    private String
    fractional seconds part of the dateTime object as String
    private String
    hour part of the dateTime object as String
    private String
    hours part of the optional timezone as String
    private int
    day part of the dateTime object as int
    private double
    fractional seconds part of the dateTime object as int
    private int
    hour part of the dateTime object as int
    private int
    hours part of the optional timezone as int
    private int
    minute part of the dateTime object as int
    private int
    minutes part of the optional timezone as int
    private int
    month part of the dateTime object as int
    private int
    second part of the dateTime object as int
    private 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 int
    private String
    minutes part of the dateTime object as String
    private String
    minutes part of the optional timezone as String
    private String
    month part of the dateTime object as String
    private String
    seconds part of the dateTime object as String
    private String
    year part of the dateTime object as String
  • Constructor Summary

    Constructors
    Constructor
    Description
    XMLDateTime(String dateTimeString)
    Creates a new XMLDateTime object for the supplied xsd:dateTime string value.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
    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 definition
    boolean
    Checks whether this object has already been normalized.
    void
    Normalizes this dateTime object.
    private void
     
    private void
     
    Returns the xsd:dateTime string-representation of this object.
    private void
     
    private void
    verifyTokenValue(String token, String expected, String errMsg)
     

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • dateTimeString

      private final 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 String year
      year part of the dateTime object as String
    • months

      private String months
      month part of the dateTime object as String
    • days

      private String days
      day part of the dateTime object as String
    • hours

      private String hours
      hour part of the dateTime object as String
    • minutes

      private String minutes
      minutes part of the dateTime object as String
    • seconds

      private String seconds
      seconds part of the dateTime object as String
    • fractionalSeconds

      private 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 String hoursTimezone
      hours part of the optional timezone as String
    • minutesTimezone

      private 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 Details

    • XMLDateTime

      public XMLDateTime(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:
      IllegalArgumentException - if the supplied lexical value does not constitute a valid xsd:dateTime.
  • Method Details

    • parseDateTimeString

      private void parseDateTimeString()
    • verifyTokenValue

      private void verifyTokenValue(String token, String expected, 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:
      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

      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.
    • toString

      public String toString()
      Returns the xsd:dateTime string-representation of this object.
      Overrides:
      toString in class 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:
      compareTo in interface Comparable<XMLDateTime>
      Throws:
      ClassCastException - If other is not a DateTime object.
    • clone

      public Object clone()
      Overrides:
      clone in class Object