System information

Appendix D. JAVA Example Code
D-10
catch(Exception e)
{
flush_io_log(e.toString());
read_index = 0;
getlinesig = 0xAAAA;
}
}
else
{
read_index = 0;
getlinesig = 0xAAAA;
}
}
}
}
catch(IOException e)
{
System.out.println("GetLine(): " + e);
}
}
static GregorianCalendar getTimeStamp( long stamp )
{
// "stamp" is in nanosecs since 1990
// we need to convert that to a Date
GregorianCalendar cal = new GregorianCalendar(1990,0,1,0,0,0);
int sec = (int)(stamp / 1000000000);
int msec = (int)((stamp % 1000000000) / 1000000);
cal.add(Calendar.SECOND, sec);
cal.add(Calendar.MILLISECOND,msec);
cal.add(Calendar.MILLISECOND,-cal.get(Calendar.DST_OFFSET));
return cal;
}
static void ParseClk()
{
try
{
byte logger_resp = in_packet.read_byte();
if(logger_resp == 0)
{
long seconds = in_packet.read_int() * nsecPerSec;
DLtime = getTimeStamp(seconds);
PCtime = new GregorianCalendar();
System.out.println("DLtime = " + DLtime.getTime());
}
else
System.out.println("Clock check failed: " + logger_resp);
}
catch(Exception e)
{
System.out.println("Clock Check Failed: " + e.toString());
}
}