Here you can find the source of timeToId(long timeInMillis)
public static long timeToId(long timeInMillis)
//package com.java2s; //License from project: Apache License import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; public class Main { private static final int BASE = 100000; private static Random RANDOM = new Random(System.currentTimeMillis()); private static AtomicInteger serial = new AtomicInteger(BASE); public static long timeToId(long timeInMillis) { if (serial.intValue() > 9900 * BASE) { serial.set(BASE);// w w w . jav a 2 s . c o m } return timeInMillis / 1000 * 1000000000 + serial.getAndAdd(BASE) + RANDOM.nextInt(BASE); } }