|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--texsoft.java.util.XsTime
The XsTime
class represents a simple time value.
It simply stores hours, minutes and seconds values without the other features of
and Date
. Calendar
An usefull feature of this class is that it implements the
interface to allow searching and
ordering.
Comparable
Constructor Summary | |
XsTime()
Creates a new XsTime object set to time 0:00:00. |
|
XsTime(int h,
int m,
int s)
Creates new XsTime object with given hour,
minute, second values. |
|
XsTime(java.lang.String s)
Create a new XsTime object set to the time value from the
string in the format HH[:MM[:SS]]. |
Method Summary | |
int |
compareTo(java.lang.Object o)
Compares this XsTime object with the specified object for order. |
int |
differenceMinutes(XsTime other)
Returns the difference in minutes between the this object and other. |
static int |
differenceMinutes(XsTime start,
XsTime stop)
Returns the diference in minutes between start and stop. |
int |
differenceSeconds(XsTime other)
Returns the difference in seconds between the this object and other. |
static int |
differenceSeconds(XsTime start,
XsTime stop)
Returns the diference in seconds between start and stop. |
static XsTime |
getCurrent()
Returns a new XsTime object set to current system time. |
int |
getHour()
Get the hour component of the time. |
int |
getMinute()
Get the minute component of the time. |
int |
getSecond()
Get the second component of the time. |
static void |
main(java.lang.String[] args)
Sample code to test the class. |
int |
minutesValue()
Returns the time value in minutes from midnight. |
int |
secondsValue()
Returns the time value in seconds from midnight. |
void |
setTime(int h,
int m,
int s)
Set time value of this XsTime object to given hour,
minute, second values. |
void |
setTime(java.lang.String s)
Set the time from to the string in the format HH[:MM[:SS]]. |
java.lang.String |
toString()
Return a String rapresentation of time value
in the format HH:MM:SS. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XsTime()
XsTime
object set to time 0:00:00.
public XsTime(int h, int m, int s)
XsTime
object with given hour,
minute, second values. Values of hour, minute and second can be any, as they are converted in seconds, so the time value is stored as hour * 3600 + minute * 60 + second seconds.
h
- hours component of time value.m
- minutes component of time value.s
- seconds component of time value.public XsTime(java.lang.String s)
XsTime
object set to the time value from the
string in the format HH[:MM[:SS]].
The separator is assumed to be the first non digit character in the String
.
s
- a String
time value in the format HH[:MM[:SS]].Method Detail |
public void setTime(int h, int m, int s)
XsTime
object to given hour,
minute, second values. Values of hour, minute and second can be any, as they are converted in seconds, so the time value is stored as hour * 3600 + minute * 60 + second seconds.
h
- hours component of time value.m
- minutes component of time value.s
- seconds component of time value.public void setTime(java.lang.String s)
s
- a String
time value in the format HH[:MM[:SS]].public int getHour()
public int getMinute()
public int getSecond()
public int minutesValue()
public int secondsValue()
public java.lang.String toString()
String
rapresentation of time value
in the format HH:MM:SS.
toString
in class java.lang.Object
public static XsTime getCurrent()
XsTime
object set to current system time.
XsTime
object set to current timepublic static int differenceMinutes(XsTime start, XsTime stop)
start
- lower XsTime
object.stop
- higher XsTime
object.
public int differenceMinutes(XsTime other)
other
- time value to be compared to this object to find difference in
minutes bewteeen them.
public static int differenceSeconds(XsTime start, XsTime stop)
start
- lower XsTime
object.stop
- higher XsTime
object.
public int differenceSeconds(XsTime other)
other
- time value to be compared to this object to find difference
in seconds bewteeen them.
public int compareTo(java.lang.Object o) throws java.lang.ClassCastException
XsTime
object with the specified object for order.
Returns a negative integer, zero, or a positive integer as this object is less
than, equal to, or greater than the specified object.
If compared to null
always return 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 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 |