|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.system.Clock
This class provides access to the TINI Real-Time clock. The methods support setting and getting the clock values (milliseconds since Jan 1, 1970).
The getTickCount()
method returns the same value as java.lang.System.currentTimeMillis()
and is included for completeness. Programmers should use System.currentTimeMillis()
for correct Java
compatibility.
...
long time = com.dalsemi.system.Clock.getTickCount();
System.out.println(new java.util.Date(time));
...
The following code sets the TINI Real-Time clock to October 4, 2000 at 1:43 in the afternoon.
...
java.util.Date myDate = new java.util.Date(2000-1900, 10-1, 4, 13, 43, 00);
long millis = myDate.getTime();
com.dalsemi.system.Clock.setTickCount(millis);
...
Note that the time printed will probably not be 1:43 PM. The time stored is
for GMT. On a TINI with Central Standard Time as the default TimeZone
, this program
prints out:
TINI /> java clockdemo.tini
Wed Oct 4 08:43:59 CST 2000
which is correct because CST during Daylight Savings Time (CDT) is 5 hours behind GMT.
Method Summary | |
static long |
getTickCount()
Get the current time in milliseconds since midnight Jan 1, 1970, UTC. |
static void |
setTickCount(long millis)
Set the current time from a value in milliseconds since Jan 1, 1970, UTC. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static long getTickCount()
Get the current time in milliseconds since midnight Jan 1, 1970, UTC.
The value returned is suitable to be used in
calls to Java classes such as java.util.Date
and
java.util.Calendar
.
Note: It it highly recommended not to call this method, and instead
use java.lang.System.currentTimeMillis()
to insure Java portability.
setTickCount(long)
public static void setTickCount(long millis)
Set the current time from a value in milliseconds since Jan 1, 1970, UTC.
This method is not written to handle negative values for
millis
. Note, the underlying hardware clock may only store
the
2 least significant digits of the year. Subsequent calls to
getTickCount()
will add these 2 digits to the year
2000 to come up with the current year. If you call
setTickCount()
with a value for a date in 1999,
then getTickCount()
may return you a value for
a date in 2099.
millis
- number of milliseconds since midnight, Jan 1, 1970 UTCgetTickCount()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |