TestSystemTimeUtilspublic class TestSystemTimeUtils extends TestCase Tests that SystemTimeUtils works properly. |
Fields Summary |
---|
private byte[] | data_a | private byte[] | data_b | private SimpleDateFormat | sdf |
Methods Summary |
---|
public void | testGetDateA()
Date date = SystemTimeUtils.getDate(data_a);
// Is 2006-01-24 (2nd day of week) 10:26:15.205
Date exp = sdf.parse("2006-01-24 10:26:15.205");
assertEquals(exp.getTime(), date.getTime());
assertEquals(exp, date);
| public void | testGetDateB()
Date date = SystemTimeUtils.getDate(data_b, 8+4);
// Is 2006-01-24 (2nd day of week) 21:25:03.725
Date exp = sdf.parse("2006-01-24 21:25:03.725");
assertEquals(exp.getTime(), date.getTime());
assertEquals(exp, date);
| public void | testWriteDateA()
byte[] out_a = new byte[data_a.length];
Date date = sdf.parse("2006-01-24 10:26:15.205");
SystemTimeUtils.storeDate(date, out_a);
for(int i=0; i<out_a.length; i++) {
assertEquals(data_a[i], out_a[i]);
}
| public void | testWriteDateB()
byte[] out_b = new byte[data_b.length];
// Copy over start and end, ignoring the 16 byte date field in the middle
System.arraycopy(data_b, 0, out_b, 0, 12);
System.arraycopy(data_b, 12+16, out_b, 12+16, data_b.length-12-16);
Date date = sdf.parse("2006-01-24 21:25:03.725");
SystemTimeUtils.storeDate(date, out_b, 12);
for(int i=0; i<out_b.length; i++) {
assertEquals(data_b[i], out_b[i]);
}
|
|