org.ucl.xpath.types
Class XSDateTime

java.lang.Object
  extended byorg.ucl.xpath.types.AnyType
      extended byorg.ucl.xpath.types.AnySimpleType
          extended byorg.ucl.xpath.types.AnyAtomicType
              extended byorg.ucl.xpath.types.CtrType
                  extended byorg.ucl.xpath.types.CalendarType
                      extended byorg.ucl.xpath.types.XSDateTime
All Implemented Interfaces:
java.lang.Cloneable, CmpEq, CmpGt, CmpLt, MathMinus, MathPlus

public class XSDateTime
extends CalendarType
implements CmpEq, CmpLt, CmpGt, MathMinus, MathPlus, java.lang.Cloneable

A representation of a date and time (and optional timezone)


Constructor Summary
XSDateTime()
          Inititates a new representation of the current date and time
XSDateTime(java.util.Calendar cal, XDTDayTimeDuration tz)
          Initiates a new represenation of a supplied date ant time
 
Method Summary
 java.util.Calendar calendar()
          Retrieves the Calendar representation of the date stored
 java.lang.Object clone()
          Creates a copy of this date and time representation
 ResultSequence constructor(ResultSequence arg)
          Creates a new result sequence consisting of the retrievable date and time value in the supplied result sequence
 int day()
          Retrieve the day from the date stored
 boolean eq(AnyType arg)
          Equality comparison on this and the supplied dates and times (taking timezones into account)
 boolean gt(AnyType arg)
          Comparison on this and the supplied dates and times (taking timezones into account)
 int hour()
          Retrieve the hour from the date stored
static boolean is_digit(char x)
          Check to see if a character is numeric
 boolean lt(AnyType arg)
          Comparison on this and the supplied dates and times (taking timezones into account)
 ResultSequence minus(ResultSequence arg)
          Mathematical minus operator between this XSDateTime and a supplied result sequence (XSDateTime, XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).
 int minute()
          Retrieve the minute from the date stored
 int month()
          Retrieve the month from the date stored
static java.lang.String pad_int(int num, int len)
          Pads the supplied number to the supplied number of digits by adding 0's in front of it
static int[] parse_date(java.lang.String str)
          Parses a String representation of a date and time and retrieves the year, month and day from it
static double[] parse_time(java.lang.String str)
          Parses a String representation of a date and time and retrieves the hour, minute and seconds from it
static int[] parse_timezone(java.lang.String str)
          Parses a String representation of a date and time and retrieves the timezone from it
static XSDateTime parseDateTime(java.lang.String str)
          Parses a String representation of a date and time and constructs a new XSDateTime object using that information
 ResultSequence plus(ResultSequence arg)
          Mathematical addition operator between this XSDateTime and a supplied result sequence (XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).
 double second()
          Retrieve the seconds from the date stored
 java.lang.String string_type()
          Retrive the datatype full pathname
 java.lang.String string_value()
          Retrieves a String representation of the date and time stored
 boolean timezoned()
           
 java.lang.String type_name()
          Retrieves the datatype name
 XDTDayTimeDuration tz()
          Retrieves the timezone associated with the date stored
 double value()
          Currently unsupported method.
 int year()
          Retrieve the year from the date stored
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSDateTime

public XSDateTime(java.util.Calendar cal,
                  XDTDayTimeDuration tz)
Initiates a new represenation of a supplied date ant time

Parameters:
cal - The Calendar representation of the date and time to be stored
tz - The timezone of the date to be stored.

XSDateTime

public XSDateTime()
Inititates a new representation of the current date and time

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a copy of this date and time representation

Returns:
A copy of this date and time representation
Throws:
java.lang.CloneNotSupportedException

type_name

public java.lang.String type_name()
Retrieves the datatype name

Specified by:
type_name in class CtrType
Returns:
"dateTime" which is the dataype name

is_digit

public static boolean is_digit(char x)
Check to see if a character is numeric

Parameters:
x - Character to be tested
Returns:
True if the character is numeric. False otherwise.

parse_date

public static int[] parse_date(java.lang.String str)
Parses a String representation of a date and time and retrieves the year, month and day from it

Parameters:
str - The String representation of the date (and optional timezone)
Returns:
Integer array of size 3. Element 1 is the year, element 2 is the month and element 3 is the day

parse_time

public static double[] parse_time(java.lang.String str)
Parses a String representation of a date and time and retrieves the hour, minute and seconds from it

Parameters:
str - The String representation of the date (and optional timezone)
Returns:
Integer array of size 3. Element 1 is the hour, element 2 is the minute and element 3 is the seconds

parse_timezone

public static int[] parse_timezone(java.lang.String str)
Parses a String representation of a date and time and retrieves the timezone from it

Parameters:
str - The String representation of the date (and optional timezone)
Returns:
Integer array of size 3. Element 1 represents whether the timezone is ahead or behind GMT, element 2 is the hour displacement and element 3 is the minute displacement.

parseDateTime

public static XSDateTime parseDateTime(java.lang.String str)
Parses a String representation of a date and time and constructs a new XSDateTime object using that information

Parameters:
str - The String representation of the date (and optional timezone)
Returns:
The XSDateTime representation of the date and time (and optional timezone)

constructor

public ResultSequence constructor(ResultSequence arg)
                           throws DynamicError
Creates a new result sequence consisting of the retrievable date and time value in the supplied result sequence

Specified by:
constructor in class CtrType
Parameters:
arg - The result sequence from which to extract the date and time value.
Returns:
A new result sequence consisting of the date and time value supplied.
Throws:
DynamicError

year

public int year()
Retrieve the year from the date stored

Returns:
the year value of the date stored

month

public int month()
Retrieve the month from the date stored

Returns:
the month value of the date stored

day

public int day()
Retrieve the day from the date stored

Returns:
the day value of the date stored

hour

public int hour()
Retrieve the hour from the date stored

Returns:
the hour value of the date stored

minute

public int minute()
Retrieve the minute from the date stored

Returns:
the minute value of the date stored

second

public double second()
Retrieve the seconds from the date stored

Returns:
the seconds value of the date stored

timezoned

public boolean timezoned()

pad_int

public static java.lang.String pad_int(int num,
                                       int len)
Pads the supplied number to the supplied number of digits by adding 0's in front of it

Parameters:
num - Number that si to be padded (if neccessay)
len - Desired length after padding
Returns:
String representation of the padded integer

string_value

public java.lang.String string_value()
Retrieves a String representation of the date and time stored

Specified by:
string_value in class AnyType
Returns:
String representation of the date and time stored

string_type

public java.lang.String string_type()
Retrive the datatype full pathname

Specified by:
string_type in class AnyType
Returns:
"xs:dateTime" which is the datatype full pathname

calendar

public java.util.Calendar calendar()
Retrieves the Calendar representation of the date stored

Returns:
Calendar representation of the date stored

eq

public boolean eq(AnyType arg)
           throws DynamicError
Equality comparison on this and the supplied dates and times (taking timezones into account)

Specified by:
eq in interface CmpEq
Parameters:
arg - XSDateTime representation of the date to compare to
Returns:
True if the two dates and times are represent the same exact point in time. False otherwise.
Throws:
DynamicError

lt

public boolean lt(AnyType arg)
           throws DynamicError
Comparison on this and the supplied dates and times (taking timezones into account)

Specified by:
lt in interface CmpLt
Parameters:
arg - XSDateTime representation of the date to compare to
Returns:
True if in time, this date and time lies before the date and time supplied. False otherwise.
Throws:
DynamicError

gt

public boolean gt(AnyType arg)
           throws DynamicError
Comparison on this and the supplied dates and times (taking timezones into account)

Specified by:
gt in interface CmpGt
Parameters:
arg - XSDateTime representation of the date to compare to
Returns:
True if in time, this date and time lies after the date and time supplied. False otherwise.
Throws:
DynamicError

tz

public XDTDayTimeDuration tz()
Retrieves the timezone associated with the date stored

Returns:
the timezone associated with the date stored

value

public double value()
Currently unsupported method. Retrieves the date in milliseconds since the begining of epoch

Returns:
Number of milliseconds since the begining of the epoch

minus

public ResultSequence minus(ResultSequence arg)
                     throws DynamicError
Mathematical minus operator between this XSDateTime and a supplied result sequence (XSDateTime, XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).

Specified by:
minus in interface MathMinus
Parameters:
arg - The supplied ResultSequence that is on the right of the minus operator. If this is an XSDateTime, the result will be a XDTDayTimeDuration of the duration of time between these two dates. If arg is an XDTYearMonthDuration or an XDTDayTimeDuration the result will be a XSDateTime of the result of the current date minus the duration of time supplied.
Returns:
New ResultSequence consisting of the result of the mathematical minus operation.
Throws:
DynamicError - Dynamic error.

plus

public ResultSequence plus(ResultSequence arg)
                    throws DynamicError
Mathematical addition operator between this XSDateTime and a supplied result sequence (XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).

Specified by:
plus in interface MathPlus
Parameters:
arg - The supplied ResultSequence that is on the right of the minus operator. If arg is an XDTYearMonthDuration or an XDTDayTimeDuration the result will be a XSDateTime of the result of the current date minus the duration of time supplied.
Returns:
New ResultSequence consisting of the result of the mathematical minus operation.
Throws:
DynamicError - Dynamic error.