Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hp.hpl.jena.datatypes.xsd
Class XSDDateTime  view XSDDateTime download XSDDateTime.java

java.lang.Object
  extended bycom.hp.hpl.jena.datatypes.xsd.AbstractDateTime
      extended bycom.hp.hpl.jena.datatypes.xsd.XSDDateTime

public class XSDDateTime
extends AbstractDateTime

Represent an XSD date/time value. Rather than have a separate type for each legal date/time value combination this is a combination type than does runtime checks whether a given field is legal in the current circumstances.

Version:
$Revision: 1.17 $ on $Date: 2005/02/21 12:02:16 $

Field Summary
static short DAY_MASK
          Mask to indicate whether day is present
static short FULL_MASK
          Mask to indicate all date/time are present
protected  short mask
          Set of legal fields for the particular date/time instance
static java.util.HashMap maskMap
          table mapping xs type name to mask of legal values
static short MONTH_MASK
          Mask to indicate whether month is present
static short TIME_MASK
          Mask to indicate whether time is present
static short YEAR_MASK
          Mask to indicate whether year is present
 
Fields inherited from class com.hp.hpl.jena.datatypes.xsd.AbstractDateTime
CY, D, data, EQUAL, fractionalSeconds, GREATER_THAN, h, hh, INDETERMINATE, LESS_THAN, m, M, mm, ms, s, TOTAL_SIZE, utc
 
Constructor Summary
XSDDateTime(java.util.Calendar date)
          Constructor - create a full DateTime object from a java calendar instance.
XSDDateTime(java.lang.Object value, int mask)
          Constructor - should only be used by the internals but public scope because the internals spread across multiple packages.
 
Method Summary
 java.util.Calendar asCalendar()
          Return the date time as a java Calendar object.
private static int[] convertCalendar(java.util.Calendar date)
          Convert a java calendar object to a new int[] in the format used by XSDAbstractDateTime
 int getDays()
          Return the number of years in the dateTime
 int getFullSeconds()
          Return the number of full seconds in the dateTime
 int getHours()
          Return the number of hours in the dateTime
 int getMinutes()
          Return the number of minutes in the dateTime
 int getMonths()
          Return the month in the dateTime, this is in ISO8601 format so january = 1
 double getSeconds()
          Return the number of seconds in the dateTime, including fractional part
 double getTimePart()
          Return the time component of the dateTime - i.e.
 int getYears()
          Return the number of years in the dateTime.
 java.lang.String toString()
          Return legal serialized form.
 
Methods inherited from class com.hp.hpl.jena.datatypes.xsd.AbstractDateTime
compare, compareDates, compareOrder, equals, extractFractionalSeconds, fQuotient, fQuotient, hashCode, maxDayInMonthFor, mod, modulo, normalize, resetDateObj
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

YEAR_MASK

public static final short YEAR_MASK
Mask to indicate whether year is present

See Also:
Constant Field Values

MONTH_MASK

public static final short MONTH_MASK
Mask to indicate whether month is present

See Also:
Constant Field Values

DAY_MASK

public static final short DAY_MASK
Mask to indicate whether day is present

See Also:
Constant Field Values

TIME_MASK

public static final short TIME_MASK
Mask to indicate whether time is present

See Also:
Constant Field Values

FULL_MASK

public static final short FULL_MASK
Mask to indicate all date/time are present

See Also:
Constant Field Values

maskMap

public static final java.util.HashMap maskMap
table mapping xs type name to mask of legal values


mask

protected short mask
Set of legal fields for the particular date/time instance

Constructor Detail

XSDDateTime

public XSDDateTime(java.lang.Object value,
                   int mask)
Constructor - should only be used by the internals but public scope because the internals spread across multiple packages.


XSDDateTime

public XSDDateTime(java.util.Calendar date)
Constructor - create a full DateTime object from a java calendar instance.

Method Detail

convertCalendar

private static int[] convertCalendar(java.util.Calendar date)
Convert a java calendar object to a new int[] in the format used by XSDAbstractDateTime


asCalendar

public java.util.Calendar asCalendar()
                              throws IllegalDateTimeFieldException
Return the date time as a java Calendar object. If the timezone has been specified then the object is normalized to GMT. If the zone has not been specified then we use the default timezone.

N.B. The millisecond field will be discarded and the resulting Calendar object will have 0 in the millisecond field. This is a workaround for an apparent problem with some Linux JDK's Calendar implementations. If it causes a problem contact us to ask us to revisit this.


getYears

public int getYears()
             throws IllegalDateTimeFieldException
Return the number of years in the dateTime.


getMonths

public int getMonths()
              throws IllegalDateTimeFieldException
Return the month in the dateTime, this is in ISO8601 format so january = 1


getDays

public int getDays()
            throws IllegalDateTimeFieldException
Return the number of years in the dateTime


getHours

public int getHours()
             throws IllegalDateTimeFieldException
Return the number of hours in the dateTime


getMinutes

public int getMinutes()
               throws IllegalDateTimeFieldException
Return the number of minutes in the dateTime


getFullSeconds

public int getFullSeconds()
                   throws IllegalDateTimeFieldException
Return the number of full seconds in the dateTime


getSeconds

public double getSeconds()
                  throws IllegalDateTimeFieldException
Return the number of seconds in the dateTime, including fractional part


getTimePart

public double getTimePart()
                   throws IllegalDateTimeFieldException
Return the time component of the dateTime - i.e. just the hours/mins/seconds, and returns the values in seconds.


toString

public java.lang.String toString()
Return legal serialized form.