import java.sql.Timestamp; public class IdConvertor { public static void main(String[] args) { // ID 转时锟斤拷 //your ID long id = 500000000002416047L; id = id % 10000000000000000L; id = id / 1000L; id = id >> 5L; id += 1542335205801L; System.out.println(new Timestamp(id)); // 时锟斤拷转 ID long xxx = System.currentTimeMillis(); xxx -= 1542335205801L; xxx = (xxx << 5L) | 31L; // 锟斤拷小 0锟斤拷锟斤拷锟 31 xxx = xxx * 1000 + 999; // 锟斤拷小 0锟斤拷 锟斤拷锟 999 xxx =150000000000000000L + xxx; System.out.println(xxx); } }