|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--texsoft.java.util.XsDateTime
The XsDateTime
represents a monent in time,
with a XsDate
and an optional XsTime
objects.
Constructor Summary | |
XsDateTime()
Creates a new empty XsDateTime object. |
|
XsDateTime(java.util.GregorianCalendar cal)
Creates a new XsDateTime object set to cal's date and time. |
|
XsDateTime(long timestamp)
Creates a new XsDateTime object
set to timestamp in milliseconds since 1970-01-01 0:00:00. |
|
XsDateTime(java.lang.String s)
Creates a new XsDateTime object, with date and time set
from the string. |
|
XsDateTime(java.lang.String d,
java.lang.String t)
Creates a new XsDateTime object, with date and time set
from the strings. |
|
XsDateTime(XsDate d)
Creates a new XsDateTime object, set date to d
and time to null . |
|
XsDateTime(XsDate d,
XsTime t)
Creates a new XsDateTime object, set date to d
and time to t. |
Method Summary | |
int |
compareTo(java.lang.Object o)
Compares this object with the specified object for order. |
static XsDateTime |
getCurrent()
Returns a new XsDateTime object set from to system date and time. |
XsDate |
getDate()
Get the date component. |
XsTime |
getTime()
Get the time component. |
boolean |
hasTime()
Returns true if the time component is not null . |
static void |
main(java.lang.String[] args)
Some simple test code. |
void |
setDate(XsDate date)
Set a new date value. |
void |
setDateTime(java.util.GregorianCalendar cal)
Set date and time from the passed GregorianCalendar object. |
void |
setDateTime(long timestamp)
Set date and time to the timestamp in milliseconds since 1970-01-01 0:00:00. |
void |
setDateTime(java.lang.String s)
Set the date and time values based on the string argument. |
void |
setDateTime(XsDate d,
XsTime t)
Set new date and time values for this object. |
void |
setTime(XsTime time)
Set a new time value. |
java.util.GregorianCalendar |
toGregorianCalendar()
Returns date and time as a GregorianCalendar object. |
long |
toMilliseconds()
Return date and time as timestamp in milliseconds since 1970-01-01 0:00:00. |
java.lang.String |
toString()
Returns date and time as string in the format YYYY-MM-DD [HH:MM:SS]. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XsDateTime()
XsDateTime
object.
Date component is set to empty XsDate
, time component is set to
null
.
public XsDateTime(java.lang.String s)
XsDateTime
object, with date and time set
from the string.
The format of the argument is a date value in the one of the formats recognized by
XsDate.setDate(String)
,
followed by an optional time value in the format recognized by
XsTime.setTime(String)
separed from the date
by one or more whitespace characters.
s
- date and optional time in one of the recognized String
formats.XsDate.setDate(String)
,
XsTime.setTime(String)
public XsDateTime(java.lang.String d, java.lang.String t)
XsDateTime
object, with date and time set
from the strings.
The format of the arguments is a date value in the one of the formats
recognized by XsDate.setDate(String)
,
and a time value in the format recognized by
XsTime.setTime(String)
.
The time is optional and can be null
.
d
- date value in one of the recognized String
formats.t
- time value in one of the recognized String
formats.XsDate.setDate(String)
,
XsTime.setTime(String)
public XsDateTime(XsDate d)
XsDateTime
object, set date to d
and time to null
.
d
- date value.public XsDateTime(XsDate d, XsTime t)
XsDateTime
object, set date to d
and time to t.
Time value is optional and can be null
.
d
- date value.t
- time value.public XsDateTime(java.util.GregorianCalendar cal)
XsDateTime
object set to cal's date and time.
cal
- time and date value.public XsDateTime(long timestamp)
XsDateTime
object
set to timestamp in milliseconds since 1970-01-01 0:00:00.
timestamp
- date and time as timestamp in milliseconds since 1970-01-01 0:00:00.Method Detail |
public void setDateTime(XsDate d, XsTime t)
null
.
d
- date value.t
- time value.public void setDateTime(java.lang.String s)
The format of the argument is a date value in the one of the formats recognized by
XsDate.setDate(String)
,
followed by an optional time value in the format recognized by
XsTime.setTime(String)
separed from the date
by one or more whitespace characters.
s
- date and optional time in one of the recognized String
formats.XsDate.setDate(String)
,
XsTime.setTime(String)
public void setDateTime(java.util.GregorianCalendar cal)
GregorianCalendar
object.
cal
- new date and time in as GregorianCalendar
object.public void setDateTime(long timestamp)
timestamp
- new date and time as timestamp in milliseconds since 1970-01-01 0:00:00.public int compareTo(java.lang.Object o) throws java.lang.ClassCastException
The argument can be another XsDateTime
object or a
object.
If a XsDate
XsDate
object is passed, it is managed as a
XsDateTime
object with time set to null
.
First the dates value are compared, if them are equal then the time values are
compared. A null
time is defined to be less that time 0:00:00.
If compared to null returns a positive value.
compareTo
in interface java.lang.Comparable
o
- the Object
to be compared.
java.lang.ClassCastException
- if the specified object's
type prevents it from being compared to this object.public XsDate getDate()
public XsTime getTime()
public void setDate(XsDate date)
date
- new date value.public void setTime(XsTime time)
time
- new time value.public boolean hasTime()
null
.
null
.public static XsDateTime getCurrent()
XsDateTime
object set from to system date and time.
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.GregorianCalendar toGregorianCalendar()
GregorianCalendar
object.
GregorianCalendar
object set with the date and time of
this object.public long toMilliseconds()
public static void main(java.lang.String[] args)
args
- command line arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |