public static <T> T[] createSample(Class<T> clazz, T[] objects, int size) {
    //Skip this process if number of items already smaller than sample size
    if (objects.length <= size) {
      return objects;
    }

    @SuppressWarnings("unchecked")
    T[] result = (T[]) Array.newInstance(clazz, size);

    //Shuffle a clone copy
    T[] clone = objects.clone();
    Collections.shuffle(Arrays.asList(clone));

    //Take the first n items
    System.arraycopy(clone, 0, result, 0, size);

    return result;
  }
Convert milliseconds to readable value

@param milliseconds The number of milliseconds
@return A String of readable time
app/com/linkedin/drelephant/math/Statistics.java