CCNTime extends Timestamp implements ContentName.ComponentProvider { @Override public void setNanos(int nanos) { _binarytime = null; int quantizedNanos = (int)(((((nanos * 4096L + 500000000L) / 1000000000L)) * 1000000000L) / 4096L); if ((quantizedNanos < 0) || (quantizedNanos > 999999999)) { System.out.println("Quantizing nanos " + nanos + " resulted in out of range value " + quantizedNanos + "!"); } super.setNanos(quantizedNanos); } 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 testSetNanos() { Log.info(Log.FAC_TEST, "Starting testSetNanos"); 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)); int newNanos = random.nextInt(CCNTime.NANOS_MAX); e2.setNanos(newNanos); c2.setNanos(newNanos); Assert.assertTrue(timestampEquals(e2, c2)); Assert.assertTrue(c2.equals(e2)); testTimestamp(c2, e2); } Log.info(Log.FAC_TEST, "Completed testSetNanos"); }
@Test public void testCCNTimeTimestamp() { Log.info(Log.FAC_TEST, "Starting testCCNTimeTimestamp"); for (int i=0; i < NUM_RUNS; ++i) { Timestamp ts2 = new Timestamp(System.currentTimeMillis()); ts2.setNanos(random.nextInt(10000000)); CCNTime t2 = new CCNTime(ts2); testTimestamp(t2, ts2); } Log.info(Log.FAC_TEST, "Completed testCCNTimeTimestamp"); }