get the unix timestamp from type 1 uuid

前端 未结 4 937
挽巷
挽巷 2021-01-12 22:13

In our java application we are trying to get the unix time from the type 1 uuid. But its not giving the correct date time values.

long time = uuid.timestamp(         


        
4条回答
  •  不思量自难忘°
    2021-01-12 22:25

    In my case, the following code worked.

        final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
        UUID uuid = UUID.fromString("6470d760-d93d-11e9-8b32-858313a776ba");
        long  time = (uuid.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) / 10000;
        // Rest of code as before
    

提交回复
热议问题