IdConvertor

2022/6/30 23:19:26

本文主要是介绍IdConvertor,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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);

    }
}

 



这篇关于IdConvertor的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程