Package org.apache.jena.datatypes.xsd
Class XSDDateTime
- java.lang.Object
-
- org.apache.jena.datatypes.xsd.AbstractDateTime
-
- org.apache.jena.datatypes.xsd.XSDDateTime
-
- All Implemented Interfaces:
java.lang.Comparable<AbstractDateTime>
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.
-
-
Field Summary
Fields Modifier and Type Field Description static short
DAY_MASK
Mask to indicate whether day is presentstatic short
FULL_MASK
Mask to indicate all date/time are presentstatic short
MONTH_MASK
Mask to indicate whether month is presentstatic short
TIME_MASK
Mask to indicate whether time is presentstatic short
YEAR_MASK
Mask to indicate whether year is present-
Fields inherited from class org.apache.jena.datatypes.xsd.AbstractDateTime
EQUAL, GREATER_THAN, INDETERMINATE, LESS_THAN
-
-
Constructor Summary
Constructors Constructor Description 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(java.util.Calendar date)
Constructor - create a full DateTime object from a java calendar instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Calendar
asCalendar()
Return the date time as a java Calendar object.int
getDays()
Return the number of years in the dateTimeint
getFullSeconds()
Return the number of full seconds in the dateTimeint
getHours()
Return the number of hours in the dateTimeint
getMinutes()
Return the number of minutes in the dateTimeint
getMonths()
Return the month in the dateTime, this is in ISO8601 format so january = 1XSDDatatype
getNarrowedDatatype()
Return the most specific xsd type which can represent this date/timedouble
getSeconds()
Return the number of seconds in the dateTime, including fractional partdouble
getTimePart()
Return the time component of the dateTime - i.e.int
getYears()
Return the number of years in the dateTime.void
narrowType(XSDDatatype dt)
Set the mask for this date/time to be that appropriate for the given XSD subtype.java.lang.String
timeLexicalForm()
Return the lexical form of the time component.java.lang.String
toString()
Return legal serialized form.
-
-
-
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
-
-
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.- Parameters:
value
- the date/time value returned by the parsingmask
- bitmask defining which components are valid in this instance (e.g. dates don't have valid time fields).
-
XSDDateTime
public XSDDateTime(java.util.Calendar date)
Constructor - create a full DateTime object from a java calendar instance.- Parameters:
date
- java calendar instance
-
-
Method Detail
-
getNarrowedDatatype
public XSDDatatype getNarrowedDatatype()
Return the most specific xsd type which can represent this date/time
-
narrowType
public void narrowType(XSDDatatype dt)
Set the mask for this date/time to be that appropriate for the given XSD subtype. If the type is a subtype of XSDdateTime the mask will be narrowed appropriately, other types will be silently ignored.
-
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.- Throws:
IllegalDateTimeFieldException
- if this is not a full date + time
-
getYears
public int getYears() throws IllegalDateTimeFieldException
Return the number of years in the dateTime.- Throws:
IllegalDateTimeFieldException
- if there is no legal year component
-
getMonths
public int getMonths() throws IllegalDateTimeFieldException
Return the month in the dateTime, this is in ISO8601 format so january = 1- Throws:
IllegalDateTimeFieldException
- if there is no legal month component
-
getDays
public int getDays() throws IllegalDateTimeFieldException
Return the number of years in the dateTime- Throws:
IllegalDateTimeFieldException
- if there is no legal day component
-
getHours
public int getHours() throws IllegalDateTimeFieldException
Return the number of hours in the dateTime- Throws:
IllegalDateTimeFieldException
- if there is no legal time component
-
getMinutes
public int getMinutes() throws IllegalDateTimeFieldException
Return the number of minutes in the dateTime- Throws:
IllegalDateTimeFieldException
- if there is no legal time component
-
getFullSeconds
public int getFullSeconds() throws IllegalDateTimeFieldException
Return the number of full seconds in the dateTime- Throws:
IllegalDateTimeFieldException
- if there is no legal time component
-
getSeconds
public double getSeconds() throws IllegalDateTimeFieldException
Return the number of seconds in the dateTime, including fractional part- Throws:
IllegalDateTimeFieldException
- if there is no legal time component
-
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.- Throws:
IllegalDateTimeFieldException
- if there is no legal time component
-
toString
public java.lang.String toString()
Return legal serialized form.- Overrides:
toString
in classjava.lang.Object
-
timeLexicalForm
public java.lang.String timeLexicalForm()
Return the lexical form of the time component.
-
-