@Test public void testTimeToNanoSeconds() { long time = System.currentTimeMillis(); long timeToNano = TimeUtils.timeToNanoSeconds(TimeUnit.MILLISECONDS, time); assertEquals(time * 1000 * 1000, timeToNano); time = System.currentTimeMillis() * 1000 * 1000; timeToNano = TimeUtils.timeToNanoSeconds(TimeUnit.NANOSECONDS, time); assertEquals(time, timeToNano); }
public static long timeToNanoSeconds(TimeUnit unit, long time) { long ts; switch (unit) { case NANOSECONDS: ts = time; break; case MICROSECONDS: ts = ((long) time * (1000)); break; case MILLISECONDS: ts = (((long) time) * 1000 * 1000); break; case SECONDS: ts = (((long) time) * (1000 * 1000 * 1000)); break; default: throw ARGUMENT_EXCEPTION; } return ts; }
TimeUtils { public static long timeToNanoSeconds(TimeUnit unit, long time) { long ts; switch (unit) { case NANOSECONDS: ts = time; break; case MICROSECONDS: ts = ((long) time * (1000)); break; case MILLISECONDS: ts = (((long) time) * 1000 * 1000); break; case SECONDS: ts = (((long) time) * (1000 * 1000 * 1000)); break; default: throw ARGUMENT_EXCEPTION; } return ts; } }
TimeUtils { public static long timeToNanoSeconds(TimeUnit unit, long time) { long ts; switch (unit) { case NANOSECONDS: ts = time; break; case MICROSECONDS: ts = ((long) time * (1000)); break; case MILLISECONDS: ts = (((long) time) * 1000 * 1000); break; case SECONDS: ts = (((long) time) * (1000 * 1000 * 1000)); break; default: throw ARGUMENT_EXCEPTION; } return ts; } private  TimeUtils(); }
TimeUtils { public static long timeToNanoSeconds(TimeUnit unit, long time) { long ts; switch (unit) { case NANOSECONDS: ts = time; break; case MICROSECONDS: ts = ((long) time * (1000)); break; case MILLISECONDS: ts = (((long) time) * 1000 * 1000); break; case SECONDS: ts = (((long) time) * (1000 * 1000 * 1000)); break; default: throw ARGUMENT_EXCEPTION; } return ts; } private  TimeUtils(); static int getTimeBucket(TimeUnit unit, long timestamp, int bucketSizeInSeconds); static int getWindowFlooredBinaryTime(TimeUnit unit, long timestamp, int windowSizeInSeconds); static int timeToSeconds(TimeUnit unit, long time); static int timeToMilliSeconds(TimeUnit unit, long time); static long timeToNanoSeconds(TimeUnit unit, long time); static int getWindowFlooredNaturalTime(int timeInSeconds, int bucketInSeconds); static long getTimeFromBucketString(String hexTimeInSeconds); static long getTimeFromBucketString(int timeInSeconds); }
TimeUtils { public static long timeToNanoSeconds(TimeUnit unit, long time) { long ts; switch (unit) { case NANOSECONDS: ts = time; break; case MICROSECONDS: ts = ((long) time * (1000)); break; case MILLISECONDS: ts = (((long) time) * 1000 * 1000); break; case SECONDS: ts = (((long) time) * (1000 * 1000 * 1000)); break; default: throw ARGUMENT_EXCEPTION; } return ts; } private  TimeUtils(); static int getTimeBucket(TimeUnit unit, long timestamp, int bucketSizeInSeconds); static int getWindowFlooredBinaryTime(TimeUnit unit, long timestamp, int windowSizeInSeconds); static int timeToSeconds(TimeUnit unit, long time); static int timeToMilliSeconds(TimeUnit unit, long time); static long timeToNanoSeconds(TimeUnit unit, long time); static int getWindowFlooredNaturalTime(int timeInSeconds, int bucketInSeconds); static long getTimeFromBucketString(String hexTimeInSeconds); static long getTimeFromBucketString(int timeInSeconds);  }