Java Reference
In-Depth Information
GetTime
requires you to specify the timeserver domain name as a command-line ar-
gument.Forexample,whenyouspecify
java GetTime time.nist.gov
,you'll
receive output similar to that shown here:
55811 11-09-07 22:03:15 50 0 0 816.1 UTC(NIST) *
This output conforms to the following NIST syntax for the Daytime protocol:
JJJJJ YR-MO-DA HH:MM:SS TT L H msADV UTC(NIST) OTM
These fields have the following meanings:
•
JJJJJ
specifies the Julian date.
•
YR-MO-DA
specifies the date in year/month/day format.
•
HH:MM:SS
specifies the time in hour/minute/second format. This time is ex-
pressed in Coordinated Universal Time (UTC)—see
ht-
•
TT
indicates whether the timer server is on Standard Time (ST) or Daylight
Saving Time (DST), where 00 indicates Standard Time and 50 indicates DST.
•
L
indicateshowtodealwithaleapsecondattheendofthemonth;it'soneof0
(no leap second), +1 (add one leap second), or -1 (subtract one leap second).
•
H
indicatesthehealthofthetimeserver.It'soneof0(healthy)orapositivein-
teger (not healthy).
•
msADV
indicatesthenumberofmillisecondsthatthetimehasbeenadvancedto
compensate for network delays.
•
UTC(NIST)
identifies the originator of the
msADV
value.
•
OTM
indicates an ontime marker.
Check out the web page at
http://www.nist.gov/pml/div688/grp40/
its.cfm
to learn more about this syntax.
Althoughyoucanreadbytesfromorwritebytestothesocketviathe
InputStream
and
OutputStream
references, you'll typically use these references as the basis
for more convenient character I/O streams by wrapping them in instances of the
java.io.BufferedReader
and
java.io.PrintWriter
classes, as demon-
strated as follows:
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
PrintWriter pw = new PrintWriter(os);
Thefirstlinecreatesareaderthatbridgesanincomingstreamofbytestoanoutgoing
streamofcharactersthataredecodedfromthebytesaccordingtothedefaultcharacter