CCNTime extends Timestamp implements ContentName.ComponentProvider { @Override public void setTime(long msec) { _binarytime = null; long binaryTimeAsLong = toBinaryTimeAsLong((msec/1000) * 1000, (msec % 1000) * 1000000L); super.setTime((binaryTimeAsLong / 4096L) * 1000L); super.setNanos((int)(((binaryTimeAsLong % 4096L) * 1000000000L) / 4096L)); } CCNTime(long msec);  CCNTime(Timestamp timestamp);  CCNTime(Date time);  CCNTime(byte [] binaryTime12);  CCNTime(); protected  CCNTime(long msec, long nanos); protected  CCNTime(long binaryTimeAsLong, boolean unused); static CCNTime fromBinaryTimeAsLong(long binaryTimeAsLong); byte [] toBinaryTime(); long toBinaryTimeAsLong(); static long toBinaryTimeAsLong(long msec, long nanos); @Override void setTime(long msec); @Override void setNanos(int nanos); void addNanos(int nanos); void increment(int timeUnits); @Override boolean equals(Timestamp ts); @Override int compareTo(Date o); @Override int compareTo(Timestamp ts); @Override boolean before(Timestamp ts); @Override boolean after(Timestamp ts); @Override boolean before(Date when); @Override boolean after(Date when); static CCNTime now(); String toShortString(); final byte[] getComponent(); static final int NANOS_MAX; }
@Test public void testSetTime() { Log.info(Log.FAC_TEST, "Starting testSetTime"); for (int i=0; i < NUM_RUNS; ++i) { Timestamp e2 = new Timestamp(early.getTime()); e2.setNanos(early.getNanos()); Assert.assertEquals(early, e2); CCNTime c2 = new CCNTime(e2); Assert.assertTrue(timestampEquals(e2, c2)); Assert.assertTrue(c2.equals(e2)); long newTime = e2.getTime() + random.nextInt(1000 * 60 * 60 * 24 * 7); e2.setTime(newTime); c2.setTime(newTime); Assert.assertTrue(timestampEquals(e2, c2)); Assert.assertTrue(c2.equals(e2)); testTimestamp(c2, e2); } Log.info(Log.FAC_TEST, "Completed testSetTime"); }